1 /* Standard problems for dataflow support routines.
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008, 2009, 2010 Free Software Foundation, Inc.
4 Originally contributed by Michael P. Hayes
5 (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
6 Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
7 and Kenneth Zadeck (zadeck@naturalbridge.com).
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation; either version 3, or (at your option) any later
16 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING3. If not see
23 <http://www.gnu.org/licenses/>. */
27 #include "coretypes.h"
31 #include "insn-config.h"
36 #include "alloc-pool.h"
38 #include "hard-reg-set.h"
39 #include "basic-block.h"
48 /* Note that turning REG_DEAD_DEBUGGING on will cause
49 gcc.c-torture/unsorted/dump-noaddr.c to fail because it prints
50 addresses in the dumps. */
52 #define REG_DEAD_DEBUGGING
55 #define DF_SPARSE_THRESHOLD 32
57 static bitmap_head seen_in_block
;
58 static bitmap_head seen_in_insn
;
61 /*----------------------------------------------------------------------------
62 Public functions access functions for the dataflow problems.
63 ----------------------------------------------------------------------------*/
64 /* Get the live at out set for BB no matter what problem happens to be
65 defined. This function is used by the register allocators who
66 choose different dataflow problems depending on the optimization
70 df_get_live_out (basic_block bb
)
75 return DF_LIVE_OUT (bb
);
77 return DF_LR_OUT (bb
);
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
82 choose different dataflow problems depending on the optimization
86 df_get_live_in (basic_block bb
)
91 return DF_LIVE_IN (bb
);
96 /*----------------------------------------------------------------------------
98 ----------------------------------------------------------------------------*/
100 /* Generic versions to get the void* version of the block info. Only
101 used inside the problem instance vectors. */
103 /* Grow the bb_info array. */
106 df_grow_bb_info (struct dataflow
*dflow
)
108 unsigned int new_size
= last_basic_block
+ 1;
109 if (dflow
->block_info_size
< new_size
)
111 new_size
+= new_size
/ 4;
112 dflow
->block_info
= XRESIZEVEC (void *, dflow
->block_info
, new_size
);
113 memset (dflow
->block_info
+ dflow
->block_info_size
, 0,
114 (new_size
- dflow
->block_info_size
) *sizeof (void *));
115 dflow
->block_info_size
= new_size
;
119 /* Dump a def-use or use-def chain for REF to FILE. */
122 df_chain_dump (struct df_link
*link
, FILE *file
)
124 fprintf (file
, "{ ");
125 for (; link
; link
= link
->next
)
127 fprintf (file
, "%c%d(bb %d insn %d) ",
128 DF_REF_REG_DEF_P (link
->ref
) ? 'd' : 'u',
129 DF_REF_ID (link
->ref
),
130 DF_REF_BBNO (link
->ref
),
131 DF_REF_IS_ARTIFICIAL (link
->ref
) ? -1 : DF_REF_INSN_UID (link
->ref
));
137 /* Print some basic block info as part of df_dump. */
140 df_print_bb_index (basic_block bb
, FILE *file
)
145 fprintf (file
, "\n( ");
146 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
148 basic_block pred
= e
->src
;
149 fprintf (file
, "%d%s ", pred
->index
, e
->flags
& EDGE_EH
? "(EH)" : "");
151 fprintf (file
, ")->[%d]->( ", bb
->index
);
152 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
154 basic_block succ
= e
->dest
;
155 fprintf (file
, "%d%s ", succ
->index
, e
->flags
& EDGE_EH
? "(EH)" : "");
157 fprintf (file
, ")\n");
161 /*----------------------------------------------------------------------------
164 Find the locations in the function where each definition site for a
165 pseudo reaches. In and out bitvectors are built for each basic
166 block. The id field in the ref is used to index into these sets.
167 See df.h for details.
168 ----------------------------------------------------------------------------*/
170 /* This problem plays a large number of games for the sake of
173 1) The order of the bits in the bitvectors. After the scanning
174 phase, all of the defs are sorted. All of the defs for the reg 0
175 are first, followed by all defs for reg 1 and so on.
177 2) There are two kill sets, one if the number of defs is less or
178 equal to DF_SPARSE_THRESHOLD and another if the number of defs is
181 <= : Data is built directly in the kill set.
183 > : One level of indirection is used to keep from generating long
184 strings of 1 bits in the kill sets. Bitvectors that are indexed
185 by the regnum are used to represent that there is a killing def
186 for the register. The confluence and transfer functions use
187 these along with the bitmap_clear_range call to remove ranges of
188 bits without actually generating a knockout vector.
190 The kill and sparse_kill and the dense_invalidated_by_call and
191 sparse_invalidated_by_call both play this game. */
193 /* Private data used to compute the solution for this problem. These
194 data structures are not accessible outside of this module. */
195 struct df_rd_problem_data
197 /* The set of defs to regs invalidated by call. */
198 bitmap_head sparse_invalidated_by_call
;
199 /* The set of defs to regs invalidate by call for rd. */
200 bitmap_head dense_invalidated_by_call
;
201 /* An obstack for the bitmaps we need for this problem. */
202 bitmap_obstack rd_bitmaps
;
205 /* Set basic block info. */
208 df_rd_set_bb_info (unsigned int index
,
209 struct df_rd_bb_info
*bb_info
)
212 gcc_assert (index
< df_rd
->block_info_size
);
213 df_rd
->block_info
[index
] = bb_info
;
217 /* Free basic block info. */
220 df_rd_free_bb_info (basic_block bb ATTRIBUTE_UNUSED
,
223 struct df_rd_bb_info
*bb_info
= (struct df_rd_bb_info
*) vbb_info
;
226 bitmap_clear (&bb_info
->kill
);
227 bitmap_clear (&bb_info
->sparse_kill
);
228 bitmap_clear (&bb_info
->gen
);
229 bitmap_clear (&bb_info
->in
);
230 bitmap_clear (&bb_info
->out
);
231 pool_free (df_rd
->block_pool
, bb_info
);
236 /* Allocate or reset bitmaps for DF_RD blocks. The solution bits are
237 not touched unless the block is new. */
240 df_rd_alloc (bitmap all_blocks
)
242 unsigned int bb_index
;
244 struct df_rd_problem_data
*problem_data
;
246 if (!df_rd
->block_pool
)
247 df_rd
->block_pool
= create_alloc_pool ("df_rd_block pool",
248 sizeof (struct df_rd_bb_info
), 50);
250 if (df_rd
->problem_data
)
252 problem_data
= (struct df_rd_problem_data
*) df_rd
->problem_data
;
253 bitmap_clear (&problem_data
->sparse_invalidated_by_call
);
254 bitmap_clear (&problem_data
->dense_invalidated_by_call
);
258 problem_data
= XNEW (struct df_rd_problem_data
);
259 df_rd
->problem_data
= problem_data
;
261 bitmap_obstack_initialize (&problem_data
->rd_bitmaps
);
262 bitmap_initialize (&problem_data
->sparse_invalidated_by_call
,
263 &problem_data
->rd_bitmaps
);
264 bitmap_initialize (&problem_data
->dense_invalidated_by_call
,
265 &problem_data
->rd_bitmaps
);
268 df_grow_bb_info (df_rd
);
270 /* Because of the clustering of all use sites for the same pseudo,
271 we have to process all of the blocks before doing the
274 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
276 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb_index
);
279 bitmap_clear (&bb_info
->kill
);
280 bitmap_clear (&bb_info
->sparse_kill
);
281 bitmap_clear (&bb_info
->gen
);
285 bb_info
= (struct df_rd_bb_info
*) pool_alloc (df_rd
->block_pool
);
286 df_rd_set_bb_info (bb_index
, bb_info
);
287 bitmap_initialize (&bb_info
->kill
, &problem_data
->rd_bitmaps
);
288 bitmap_initialize (&bb_info
->sparse_kill
, &problem_data
->rd_bitmaps
);
289 bitmap_initialize (&bb_info
->gen
, &problem_data
->rd_bitmaps
);
290 bitmap_initialize (&bb_info
->in
, &problem_data
->rd_bitmaps
);
291 bitmap_initialize (&bb_info
->out
, &problem_data
->rd_bitmaps
);
294 df_rd
->optional_p
= true;
298 /* Add the effect of the top artificial defs of BB to the reaching definitions
302 df_rd_simulate_artificial_defs_at_top (basic_block bb
, bitmap local_rd
)
304 int bb_index
= bb
->index
;
306 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
308 df_ref def
= *def_rec
;
309 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
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
));
321 /* Add the effect of the defs of INSN to the reaching definitions bitmap
325 df_rd_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED
, rtx insn
,
328 unsigned uid
= INSN_UID (insn
);
331 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
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
))
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
));
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
355 df_rd_bb_local_compute_process_def (struct df_rd_bb_info
*bb_info
,
361 df_ref def
= *def_rec
;
362 if (top_flag
== (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
))
364 unsigned int regno
= DF_REF_REGNO (def
);
365 unsigned int begin
= DF_DEFS_BEGIN (regno
);
366 unsigned int n_defs
= DF_DEFS_COUNT (regno
);
368 if ((!(df
->changeable_flags
& DF_NO_HARD_REGS
))
369 || (regno
>= FIRST_PSEUDO_REGISTER
))
371 /* Only the last def(s) for a regno in the block has any
373 if (!bitmap_bit_p (&seen_in_block
, regno
))
375 /* The first def for regno in insn gets to knock out the
376 defs from other instructions. */
377 if ((!bitmap_bit_p (&seen_in_insn
, regno
))
378 /* If the def is to only part of the reg, it does
379 not kill the other defs that reach here. */
380 && (!(DF_REF_FLAGS (def
) &
381 (DF_REF_PARTIAL
| DF_REF_CONDITIONAL
| DF_REF_MAY_CLOBBER
))))
383 if (n_defs
> DF_SPARSE_THRESHOLD
)
385 bitmap_set_bit (&bb_info
->sparse_kill
, regno
);
386 bitmap_clear_range(&bb_info
->gen
, begin
, n_defs
);
390 bitmap_set_range (&bb_info
->kill
, begin
, n_defs
);
391 bitmap_clear_range (&bb_info
->gen
, begin
, n_defs
);
395 bitmap_set_bit (&seen_in_insn
, regno
);
396 /* All defs for regno in the instruction may be put into
398 if (!(DF_REF_FLAGS (def
)
399 & (DF_REF_MUST_CLOBBER
| DF_REF_MAY_CLOBBER
)))
400 bitmap_set_bit (&bb_info
->gen
, DF_REF_ID (def
));
408 /* Compute local reaching def info for basic block BB. */
411 df_rd_bb_local_compute (unsigned int bb_index
)
413 basic_block bb
= BASIC_BLOCK (bb_index
);
414 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb_index
);
417 bitmap_clear (&seen_in_block
);
418 bitmap_clear (&seen_in_insn
);
420 /* Artificials are only hard regs. */
421 if (!(df
->changeable_flags
& DF_NO_HARD_REGS
))
422 df_rd_bb_local_compute_process_def (bb_info
,
423 df_get_artificial_defs (bb_index
),
426 FOR_BB_INSNS_REVERSE (bb
, insn
)
428 unsigned int uid
= INSN_UID (insn
);
433 df_rd_bb_local_compute_process_def (bb_info
,
434 DF_INSN_UID_DEFS (uid
), 0);
436 /* This complex dance with the two bitmaps is required because
437 instructions can assign twice to the same pseudo. This
438 generally happens with calls that will have one def for the
439 result and another def for the clobber. If only one vector
440 is used and the clobber goes first, the result will be
442 bitmap_ior_into (&seen_in_block
, &seen_in_insn
);
443 bitmap_clear (&seen_in_insn
);
446 /* Process the artificial defs at the top of the block last since we
447 are going backwards through the block and these are logically at
449 if (!(df
->changeable_flags
& DF_NO_HARD_REGS
))
450 df_rd_bb_local_compute_process_def (bb_info
,
451 df_get_artificial_defs (bb_index
),
456 /* Compute local reaching def info for each basic block within BLOCKS. */
459 df_rd_local_compute (bitmap all_blocks
)
461 unsigned int bb_index
;
464 struct df_rd_problem_data
*problem_data
465 = (struct df_rd_problem_data
*) df_rd
->problem_data
;
466 bitmap sparse_invalidated
= &problem_data
->sparse_invalidated_by_call
;
467 bitmap dense_invalidated
= &problem_data
->dense_invalidated_by_call
;
469 bitmap_initialize (&seen_in_block
, &df_bitmap_obstack
);
470 bitmap_initialize (&seen_in_insn
, &df_bitmap_obstack
);
472 df_maybe_reorganize_def_refs (DF_REF_ORDER_BY_REG
);
474 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
476 df_rd_bb_local_compute (bb_index
);
479 /* Set up the knockout bit vectors to be applied across EH_EDGES. */
480 EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset
, 0, regno
, bi
)
482 if (DF_DEFS_COUNT (regno
) > DF_SPARSE_THRESHOLD
)
483 bitmap_set_bit (sparse_invalidated
, regno
);
485 bitmap_set_range (dense_invalidated
,
486 DF_DEFS_BEGIN (regno
),
487 DF_DEFS_COUNT (regno
));
490 bitmap_clear (&seen_in_block
);
491 bitmap_clear (&seen_in_insn
);
495 /* Initialize the solution bit vectors for problem. */
498 df_rd_init_solution (bitmap all_blocks
)
500 unsigned int bb_index
;
503 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
505 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb_index
);
507 bitmap_copy (&bb_info
->out
, &bb_info
->gen
);
508 bitmap_clear (&bb_info
->in
);
512 /* In of target gets or of out of source. */
515 df_rd_confluence_n (edge e
)
517 bitmap op1
= &df_rd_get_bb_info (e
->dest
->index
)->in
;
518 bitmap op2
= &df_rd_get_bb_info (e
->src
->index
)->out
;
520 if (e
->flags
& EDGE_FAKE
)
523 if (e
->flags
& EDGE_EH
)
525 struct df_rd_problem_data
*problem_data
526 = (struct df_rd_problem_data
*) df_rd
->problem_data
;
527 bitmap sparse_invalidated
= &problem_data
->sparse_invalidated_by_call
;
528 bitmap dense_invalidated
= &problem_data
->dense_invalidated_by_call
;
533 bitmap_initialize (&tmp
, &df_bitmap_obstack
);
534 bitmap_copy (&tmp
, op2
);
535 bitmap_and_compl_into (&tmp
, dense_invalidated
);
537 EXECUTE_IF_SET_IN_BITMAP (sparse_invalidated
, 0, regno
, bi
)
539 bitmap_clear_range (&tmp
,
540 DF_DEFS_BEGIN (regno
),
541 DF_DEFS_COUNT (regno
));
543 bitmap_ior_into (op1
, &tmp
);
547 bitmap_ior_into (op1
, op2
);
551 /* Transfer function. */
554 df_rd_transfer_function (int bb_index
)
556 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb_index
);
559 bitmap in
= &bb_info
->in
;
560 bitmap out
= &bb_info
->out
;
561 bitmap gen
= &bb_info
->gen
;
562 bitmap kill
= &bb_info
->kill
;
563 bitmap sparse_kill
= &bb_info
->sparse_kill
;
565 if (bitmap_empty_p (sparse_kill
))
566 return bitmap_ior_and_compl (out
, gen
, in
, kill
);
569 struct df_rd_problem_data
*problem_data
;
570 bool changed
= false;
573 /* Note that TMP is _not_ a temporary bitmap if we end up replacing
574 OUT with TMP. Therefore, allocate TMP in the RD bitmaps obstack. */
575 problem_data
= (struct df_rd_problem_data
*) df_rd
->problem_data
;
576 bitmap_initialize (&tmp
, &problem_data
->rd_bitmaps
);
578 bitmap_copy (&tmp
, in
);
579 EXECUTE_IF_SET_IN_BITMAP (sparse_kill
, 0, regno
, bi
)
581 bitmap_clear_range (&tmp
,
582 DF_DEFS_BEGIN (regno
),
583 DF_DEFS_COUNT (regno
));
585 bitmap_and_compl_into (&tmp
, kill
);
586 bitmap_ior_into (&tmp
, gen
);
587 changed
= !bitmap_equal_p (&tmp
, out
);
600 /* Free all storage associated with the problem. */
605 struct df_rd_problem_data
*problem_data
606 = (struct df_rd_problem_data
*) df_rd
->problem_data
;
610 free_alloc_pool (df_rd
->block_pool
);
611 bitmap_obstack_release (&problem_data
->rd_bitmaps
);
613 df_rd
->block_info_size
= 0;
614 free (df_rd
->block_info
);
615 free (df_rd
->problem_data
);
621 /* Debugging info. */
624 df_rd_start_dump (FILE *file
)
626 struct df_rd_problem_data
*problem_data
627 = (struct df_rd_problem_data
*) df_rd
->problem_data
;
628 unsigned int m
= DF_REG_SIZE(df
);
631 if (!df_rd
->block_info
)
634 fprintf (file
, ";; Reaching defs:\n\n");
636 fprintf (file
, " sparse invalidated \t");
637 dump_bitmap (file
, &problem_data
->sparse_invalidated_by_call
);
638 fprintf (file
, " dense invalidated \t");
639 dump_bitmap (file
, &problem_data
->dense_invalidated_by_call
);
641 for (regno
= 0; regno
< m
; regno
++)
642 if (DF_DEFS_COUNT (regno
))
643 fprintf (file
, "%d[%d,%d] ", regno
,
644 DF_DEFS_BEGIN (regno
),
645 DF_DEFS_COUNT (regno
));
646 fprintf (file
, "\n");
651 /* Debugging info at top of bb. */
654 df_rd_top_dump (basic_block bb
, FILE *file
)
656 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb
->index
);
660 fprintf (file
, ";; rd in \t(%d)\n", (int) bitmap_count_bits (&bb_info
->in
));
661 dump_bitmap (file
, &bb_info
->in
);
662 fprintf (file
, ";; rd gen \t(%d)\n", (int) bitmap_count_bits (&bb_info
->gen
));
663 dump_bitmap (file
, &bb_info
->gen
);
664 fprintf (file
, ";; rd kill\t(%d)\n", (int) bitmap_count_bits (&bb_info
->kill
));
665 dump_bitmap (file
, &bb_info
->kill
);
669 /* Debugging info at top of bb. */
672 df_rd_bottom_dump (basic_block bb
, FILE *file
)
674 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb
->index
);
678 fprintf (file
, ";; rd out \t(%d)\n", (int) bitmap_count_bits (&bb_info
->out
));
679 dump_bitmap (file
, &bb_info
->out
);
682 /* All of the information associated with every instance of the problem. */
684 static struct df_problem problem_RD
=
686 DF_RD
, /* Problem id. */
687 DF_FORWARD
, /* Direction. */
688 df_rd_alloc
, /* Allocate the problem specific data. */
689 NULL
, /* Reset global information. */
690 df_rd_free_bb_info
, /* Free basic block info. */
691 df_rd_local_compute
, /* Local compute function. */
692 df_rd_init_solution
, /* Init the solution specific data. */
693 df_worklist_dataflow
, /* Worklist solver. */
694 NULL
, /* Confluence operator 0. */
695 df_rd_confluence_n
, /* Confluence operator n. */
696 df_rd_transfer_function
, /* Transfer function. */
697 NULL
, /* Finalize function. */
698 df_rd_free
, /* Free all of the problem information. */
699 df_rd_free
, /* Remove this problem from the stack of dataflow problems. */
700 df_rd_start_dump
, /* Debugging. */
701 df_rd_top_dump
, /* Debugging start block. */
702 df_rd_bottom_dump
, /* Debugging end block. */
703 NULL
, /* Incremental solution verify start. */
704 NULL
, /* Incremental solution verify end. */
705 NULL
, /* Dependent problem. */
706 TV_DF_RD
, /* Timing variable. */
707 true /* Reset blocks on dropping out of blocks_to_analyze. */
712 /* Create a new RD instance and add it to the existing instance
716 df_rd_add_problem (void)
718 df_add_problem (&problem_RD
);
723 /*----------------------------------------------------------------------------
726 Find the locations in the function where any use of a pseudo can
727 reach in the backwards direction. In and out bitvectors are built
728 for each basic block. The regno is used to index into these sets.
729 See df.h for details.
730 ----------------------------------------------------------------------------*/
732 /* Private data used to verify the solution for this problem. */
733 struct df_lr_problem_data
737 /* An obstack for the bitmaps we need for this problem. */
738 bitmap_obstack lr_bitmaps
;
742 /* Set basic block info. */
745 df_lr_set_bb_info (unsigned int index
,
746 struct df_lr_bb_info
*bb_info
)
749 gcc_assert (index
< df_lr
->block_info_size
);
750 df_lr
->block_info
[index
] = bb_info
;
754 /* Free basic block info. */
757 df_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED
,
760 struct df_lr_bb_info
*bb_info
= (struct df_lr_bb_info
*) vbb_info
;
763 bitmap_clear (&bb_info
->use
);
764 bitmap_clear (&bb_info
->def
);
765 bitmap_clear (&bb_info
->in
);
766 bitmap_clear (&bb_info
->out
);
767 pool_free (df_lr
->block_pool
, bb_info
);
772 /* Allocate or reset bitmaps for DF_LR blocks. The solution bits are
773 not touched unless the block is new. */
776 df_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
778 unsigned int bb_index
;
780 struct df_lr_problem_data
*problem_data
;
782 if (!df_lr
->block_pool
)
783 df_lr
->block_pool
= create_alloc_pool ("df_lr_block pool",
784 sizeof (struct df_lr_bb_info
), 50);
786 df_grow_bb_info (df_lr
);
787 if (df_lr
->problem_data
)
788 problem_data
= (struct df_lr_problem_data
*) df_lr
->problem_data
;
791 problem_data
= XNEW (struct df_lr_problem_data
);
792 df_lr
->problem_data
= problem_data
;
794 problem_data
->out
= NULL
;
795 problem_data
->in
= NULL
;
796 bitmap_obstack_initialize (&problem_data
->lr_bitmaps
);
799 EXECUTE_IF_SET_IN_BITMAP (df_lr
->out_of_date_transfer_functions
, 0, bb_index
, bi
)
801 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb_index
);
804 bitmap_clear (&bb_info
->def
);
805 bitmap_clear (&bb_info
->use
);
809 bb_info
= (struct df_lr_bb_info
*) pool_alloc (df_lr
->block_pool
);
810 df_lr_set_bb_info (bb_index
, bb_info
);
811 bitmap_initialize (&bb_info
->use
, &problem_data
->lr_bitmaps
);
812 bitmap_initialize (&bb_info
->def
, &problem_data
->lr_bitmaps
);
813 bitmap_initialize (&bb_info
->in
, &problem_data
->lr_bitmaps
);
814 bitmap_initialize (&bb_info
->out
, &problem_data
->lr_bitmaps
);
818 df_lr
->optional_p
= false;
822 /* Reset the global solution for recalculation. */
825 df_lr_reset (bitmap all_blocks
)
827 unsigned int bb_index
;
830 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
832 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb_index
);
833 gcc_assert (bb_info
);
834 bitmap_clear (&bb_info
->in
);
835 bitmap_clear (&bb_info
->out
);
840 /* Compute local live register info for basic block BB. */
843 df_lr_bb_local_compute (unsigned int bb_index
)
845 basic_block bb
= BASIC_BLOCK (bb_index
);
846 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb_index
);
851 /* Process the registers set in an exception handler. */
852 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
854 df_ref def
= *def_rec
;
855 if ((DF_REF_FLAGS (def
) & DF_REF_AT_TOP
) == 0)
857 unsigned int dregno
= DF_REF_REGNO (def
);
858 bitmap_set_bit (&bb_info
->def
, dregno
);
859 bitmap_clear_bit (&bb_info
->use
, dregno
);
863 /* Process the hardware registers that are always live. */
864 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
866 df_ref use
= *use_rec
;
867 /* Add use to set of uses in this BB. */
868 if ((DF_REF_FLAGS (use
) & DF_REF_AT_TOP
) == 0)
869 bitmap_set_bit (&bb_info
->use
, DF_REF_REGNO (use
));
872 FOR_BB_INSNS_REVERSE (bb
, insn
)
874 unsigned int uid
= INSN_UID (insn
);
876 if (!NONDEBUG_INSN_P (insn
))
879 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
881 df_ref def
= *def_rec
;
882 /* If the def is to only part of the reg, it does
883 not kill the other defs that reach here. */
884 if (!(DF_REF_FLAGS (def
) & (DF_REF_PARTIAL
| DF_REF_CONDITIONAL
)))
886 unsigned int dregno
= DF_REF_REGNO (def
);
887 bitmap_set_bit (&bb_info
->def
, dregno
);
888 bitmap_clear_bit (&bb_info
->use
, dregno
);
892 for (use_rec
= DF_INSN_UID_USES (uid
); *use_rec
; use_rec
++)
894 df_ref use
= *use_rec
;
895 /* Add use to set of uses in this BB. */
896 bitmap_set_bit (&bb_info
->use
, DF_REF_REGNO (use
));
900 /* Process the registers set in an exception handler or the hard
901 frame pointer if this block is the target of a non local
903 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
905 df_ref def
= *def_rec
;
906 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
908 unsigned int dregno
= DF_REF_REGNO (def
);
909 bitmap_set_bit (&bb_info
->def
, dregno
);
910 bitmap_clear_bit (&bb_info
->use
, dregno
);
915 /* Process the uses that are live into an exception handler. */
916 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
918 df_ref use
= *use_rec
;
919 /* Add use to set of uses in this BB. */
920 if (DF_REF_FLAGS (use
) & DF_REF_AT_TOP
)
921 bitmap_set_bit (&bb_info
->use
, DF_REF_REGNO (use
));
925 /* If the df_live problem is not defined, such as at -O0 and -O1, we
926 still need to keep the luids up to date. This is normally done
927 in the df_live problem since this problem has a forwards
930 df_recompute_luids (bb
);
934 /* Compute local live register info for each basic block within BLOCKS. */
937 df_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED
)
939 unsigned int bb_index
;
942 bitmap_clear (&df
->hardware_regs_used
);
944 /* The all-important stack pointer must always be live. */
945 bitmap_set_bit (&df
->hardware_regs_used
, STACK_POINTER_REGNUM
);
947 /* Before reload, there are a few registers that must be forced
948 live everywhere -- which might not already be the case for
949 blocks within infinite loops. */
950 if (!reload_completed
)
952 /* Any reference to any pseudo before reload is a potential
953 reference of the frame pointer. */
954 bitmap_set_bit (&df
->hardware_regs_used
, FRAME_POINTER_REGNUM
);
956 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
957 /* Pseudos with argument area equivalences may require
958 reloading via the argument pointer. */
959 if (fixed_regs
[ARG_POINTER_REGNUM
])
960 bitmap_set_bit (&df
->hardware_regs_used
, ARG_POINTER_REGNUM
);
963 /* Any constant, or pseudo with constant equivalences, may
964 require reloading from memory using the pic register. */
965 if ((unsigned) PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
966 && fixed_regs
[PIC_OFFSET_TABLE_REGNUM
])
967 bitmap_set_bit (&df
->hardware_regs_used
, PIC_OFFSET_TABLE_REGNUM
);
970 EXECUTE_IF_SET_IN_BITMAP (df_lr
->out_of_date_transfer_functions
, 0, bb_index
, bi
)
972 if (bb_index
== EXIT_BLOCK
)
974 /* The exit block is special for this problem and its bits are
975 computed from thin air. */
976 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (EXIT_BLOCK
);
977 bitmap_copy (&bb_info
->use
, df
->exit_block_uses
);
980 df_lr_bb_local_compute (bb_index
);
983 bitmap_clear (df_lr
->out_of_date_transfer_functions
);
987 /* Initialize the solution vectors. */
990 df_lr_init (bitmap all_blocks
)
992 unsigned int bb_index
;
995 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
997 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb_index
);
998 bitmap_copy (&bb_info
->in
, &bb_info
->use
);
999 bitmap_clear (&bb_info
->out
);
1004 /* Confluence function that processes infinite loops. This might be a
1005 noreturn function that throws. And even if it isn't, getting the
1006 unwind info right helps debugging. */
1008 df_lr_confluence_0 (basic_block bb
)
1010 bitmap op1
= &df_lr_get_bb_info (bb
->index
)->out
;
1011 if (bb
!= EXIT_BLOCK_PTR
)
1012 bitmap_copy (op1
, &df
->hardware_regs_used
);
1016 /* Confluence function that ignores fake edges. */
1019 df_lr_confluence_n (edge e
)
1021 bitmap op1
= &df_lr_get_bb_info (e
->src
->index
)->out
;
1022 bitmap op2
= &df_lr_get_bb_info (e
->dest
->index
)->in
;
1024 /* Call-clobbered registers die across exception and call edges. */
1025 /* ??? Abnormal call edges ignored for the moment, as this gets
1026 confused by sibling call edges, which crashes reg-stack. */
1027 if (e
->flags
& EDGE_EH
)
1028 bitmap_ior_and_compl_into (op1
, op2
, regs_invalidated_by_call_regset
);
1030 bitmap_ior_into (op1
, op2
);
1032 bitmap_ior_into (op1
, &df
->hardware_regs_used
);
1036 /* Transfer function. */
1039 df_lr_transfer_function (int bb_index
)
1041 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb_index
);
1042 bitmap in
= &bb_info
->in
;
1043 bitmap out
= &bb_info
->out
;
1044 bitmap use
= &bb_info
->use
;
1045 bitmap def
= &bb_info
->def
;
1047 return bitmap_ior_and_compl (in
, use
, out
, def
);
1051 /* Run the fast dce as a side effect of building LR. */
1054 df_lr_finalize (bitmap all_blocks
)
1056 df_lr
->solutions_dirty
= false;
1057 if (df
->changeable_flags
& DF_LR_RUN_DCE
)
1061 /* If dce deletes some instructions, we need to recompute the lr
1062 solution before proceeding further. The problem is that fast
1063 dce is a pessimestic dataflow algorithm. In the case where
1064 it deletes a statement S inside of a loop, the uses inside of
1065 S may not be deleted from the dataflow solution because they
1066 were carried around the loop. While it is conservatively
1067 correct to leave these extra bits, the standards of df
1068 require that we maintain the best possible (least fixed
1069 point) solution. The only way to do that is to redo the
1070 iteration from the beginning. See PR35805 for an
1072 if (df_lr
->solutions_dirty
)
1074 df_clear_flags (DF_LR_RUN_DCE
);
1075 df_lr_alloc (all_blocks
);
1076 df_lr_local_compute (all_blocks
);
1077 df_worklist_dataflow (df_lr
, all_blocks
, df
->postorder
, df
->n_blocks
);
1078 df_lr_finalize (all_blocks
);
1079 df_set_flags (DF_LR_RUN_DCE
);
1085 /* Free all storage associated with the problem. */
1090 struct df_lr_problem_data
*problem_data
1091 = (struct df_lr_problem_data
*) df_lr
->problem_data
;
1092 if (df_lr
->block_info
)
1094 free_alloc_pool (df_lr
->block_pool
);
1096 df_lr
->block_info_size
= 0;
1097 free (df_lr
->block_info
);
1098 bitmap_obstack_release (&problem_data
->lr_bitmaps
);
1099 free (df_lr
->problem_data
);
1100 df_lr
->problem_data
= NULL
;
1103 BITMAP_FREE (df_lr
->out_of_date_transfer_functions
);
1108 /* Debugging info at top of bb. */
1111 df_lr_top_dump (basic_block bb
, FILE *file
)
1113 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb
->index
);
1114 struct df_lr_problem_data
*problem_data
;
1118 fprintf (file
, ";; lr in \t");
1119 df_print_regset (file
, &bb_info
->in
);
1120 if (df_lr
->problem_data
)
1122 problem_data
= (struct df_lr_problem_data
*)df_lr
->problem_data
;
1123 if (problem_data
->in
)
1125 fprintf (file
, ";; old in \t");
1126 df_print_regset (file
, &problem_data
->in
[bb
->index
]);
1129 fprintf (file
, ";; lr use \t");
1130 df_print_regset (file
, &bb_info
->use
);
1131 fprintf (file
, ";; lr def \t");
1132 df_print_regset (file
, &bb_info
->def
);
1136 /* Debugging info at bottom of bb. */
1139 df_lr_bottom_dump (basic_block bb
, FILE *file
)
1141 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb
->index
);
1142 struct df_lr_problem_data
*problem_data
;
1146 fprintf (file
, ";; lr out \t");
1147 df_print_regset (file
, &bb_info
->out
);
1148 if (df_lr
->problem_data
)
1150 problem_data
= (struct df_lr_problem_data
*)df_lr
->problem_data
;
1151 if (problem_data
->out
)
1153 fprintf (file
, ";; old out \t");
1154 df_print_regset (file
, &problem_data
->out
[bb
->index
]);
1160 /* Build the datastructure to verify that the solution to the dataflow
1161 equations is not dirty. */
1164 df_lr_verify_solution_start (void)
1167 struct df_lr_problem_data
*problem_data
;
1168 if (df_lr
->solutions_dirty
)
1171 /* Set it true so that the solution is recomputed. */
1172 df_lr
->solutions_dirty
= true;
1174 problem_data
= (struct df_lr_problem_data
*)df_lr
->problem_data
;
1175 problem_data
->in
= XNEWVEC (bitmap_head
, last_basic_block
);
1176 problem_data
->out
= XNEWVEC (bitmap_head
, last_basic_block
);
1180 bitmap_initialize (&problem_data
->in
[bb
->index
], &problem_data
->lr_bitmaps
);
1181 bitmap_initialize (&problem_data
->out
[bb
->index
], &problem_data
->lr_bitmaps
);
1182 bitmap_copy (&problem_data
->in
[bb
->index
], DF_LR_IN (bb
));
1183 bitmap_copy (&problem_data
->out
[bb
->index
], DF_LR_OUT (bb
));
1188 /* Compare the saved datastructure and the new solution to the dataflow
1192 df_lr_verify_solution_end (void)
1194 struct df_lr_problem_data
*problem_data
;
1197 problem_data
= (struct df_lr_problem_data
*)df_lr
->problem_data
;
1199 if (!problem_data
->out
)
1202 if (df_lr
->solutions_dirty
)
1203 /* Do not check if the solution is still dirty. See the comment
1204 in df_lr_finalize for details. */
1205 df_lr
->solutions_dirty
= false;
1209 if ((!bitmap_equal_p (&problem_data
->in
[bb
->index
], DF_LR_IN (bb
)))
1210 || (!bitmap_equal_p (&problem_data
->out
[bb
->index
], DF_LR_OUT (bb
))))
1212 /*df_dump (stderr);*/
1217 /* Cannot delete them immediately because you may want to dump them
1218 if the comparison fails. */
1221 bitmap_clear (&problem_data
->in
[bb
->index
]);
1222 bitmap_clear (&problem_data
->out
[bb
->index
]);
1225 free (problem_data
->in
);
1226 free (problem_data
->out
);
1227 problem_data
->in
= NULL
;
1228 problem_data
->out
= NULL
;
1232 /* All of the information associated with every instance of the problem. */
1234 static struct df_problem problem_LR
=
1236 DF_LR
, /* Problem id. */
1237 DF_BACKWARD
, /* Direction. */
1238 df_lr_alloc
, /* Allocate the problem specific data. */
1239 df_lr_reset
, /* Reset global information. */
1240 df_lr_free_bb_info
, /* Free basic block info. */
1241 df_lr_local_compute
, /* Local compute function. */
1242 df_lr_init
, /* Init the solution specific data. */
1243 df_worklist_dataflow
, /* Worklist solver. */
1244 df_lr_confluence_0
, /* Confluence operator 0. */
1245 df_lr_confluence_n
, /* Confluence operator n. */
1246 df_lr_transfer_function
, /* Transfer function. */
1247 df_lr_finalize
, /* Finalize function. */
1248 df_lr_free
, /* Free all of the problem information. */
1249 NULL
, /* Remove this problem from the stack of dataflow problems. */
1250 NULL
, /* Debugging. */
1251 df_lr_top_dump
, /* Debugging start block. */
1252 df_lr_bottom_dump
, /* Debugging end block. */
1253 df_lr_verify_solution_start
,/* Incremental solution verify start. */
1254 df_lr_verify_solution_end
, /* Incremental solution verify end. */
1255 NULL
, /* Dependent problem. */
1256 TV_DF_LR
, /* Timing variable. */
1257 false /* Reset blocks on dropping out of blocks_to_analyze. */
1261 /* Create a new DATAFLOW instance and add it to an existing instance
1262 of DF. The returned structure is what is used to get at the
1266 df_lr_add_problem (void)
1268 df_add_problem (&problem_LR
);
1269 /* These will be initialized when df_scan_blocks processes each
1271 df_lr
->out_of_date_transfer_functions
= BITMAP_ALLOC (NULL
);
1275 /* Verify that all of the lr related info is consistent and
1279 df_lr_verify_transfer_functions (void)
1282 bitmap_head saved_def
;
1283 bitmap_head saved_use
;
1284 bitmap_head all_blocks
;
1289 bitmap_initialize (&saved_def
, &bitmap_default_obstack
);
1290 bitmap_initialize (&saved_use
, &bitmap_default_obstack
);
1291 bitmap_initialize (&all_blocks
, &bitmap_default_obstack
);
1295 struct df_lr_bb_info
*bb_info
= df_lr_get_bb_info (bb
->index
);
1296 bitmap_set_bit (&all_blocks
, bb
->index
);
1300 /* Make a copy of the transfer functions and then compute
1301 new ones to see if the transfer functions have
1303 if (!bitmap_bit_p (df_lr
->out_of_date_transfer_functions
,
1306 bitmap_copy (&saved_def
, &bb_info
->def
);
1307 bitmap_copy (&saved_use
, &bb_info
->use
);
1308 bitmap_clear (&bb_info
->def
);
1309 bitmap_clear (&bb_info
->use
);
1311 df_lr_bb_local_compute (bb
->index
);
1312 gcc_assert (bitmap_equal_p (&saved_def
, &bb_info
->def
));
1313 gcc_assert (bitmap_equal_p (&saved_use
, &bb_info
->use
));
1318 /* If we do not have basic block info, the block must be in
1319 the list of dirty blocks or else some one has added a
1320 block behind our backs. */
1321 gcc_assert (bitmap_bit_p (df_lr
->out_of_date_transfer_functions
,
1324 /* Make sure no one created a block without following
1326 gcc_assert (df_scan_get_bb_info (bb
->index
));
1329 /* Make sure there are no dirty bits in blocks that have been deleted. */
1330 gcc_assert (!bitmap_intersect_compl_p (df_lr
->out_of_date_transfer_functions
,
1333 bitmap_clear (&saved_def
);
1334 bitmap_clear (&saved_use
);
1335 bitmap_clear (&all_blocks
);
1340 /*----------------------------------------------------------------------------
1341 LIVE AND MUST-INITIALIZED REGISTERS.
1343 This problem first computes the IN and OUT bitvectors for the
1344 must-initialized registers problems, which is a forward problem.
1345 It gives the set of registers for which we MUST have an available
1346 definition on any path from the entry block to the entry/exit of
1347 a basic block. Sets generate a definition, while clobbers kill
1350 In and out bitvectors are built for each basic block and are indexed by
1351 regnum (see df.h for details). In and out bitvectors in struct
1352 df_live_bb_info actually refers to the must-initialized problem;
1354 Then, the in and out sets for the LIVE problem itself are computed.
1355 These are the logical AND of the IN and OUT sets from the LR problem
1356 and the must-initialized problem.
1357 ----------------------------------------------------------------------------*/
1359 /* Private data used to verify the solution for this problem. */
1360 struct df_live_problem_data
1364 /* An obstack for the bitmaps we need for this problem. */
1365 bitmap_obstack live_bitmaps
;
1368 /* Scratch var used by transfer functions. This is used to implement
1369 an optimization to reduce the amount of space used to compute the
1370 combined lr and live analysis. */
1371 static bitmap_head df_live_scratch
;
1373 /* Set basic block info. */
1376 df_live_set_bb_info (unsigned int index
,
1377 struct df_live_bb_info
*bb_info
)
1379 gcc_assert (df_live
);
1380 gcc_assert (index
< df_live
->block_info_size
);
1381 df_live
->block_info
[index
] = bb_info
;
1385 /* Free basic block info. */
1388 df_live_free_bb_info (basic_block bb ATTRIBUTE_UNUSED
,
1391 struct df_live_bb_info
*bb_info
= (struct df_live_bb_info
*) vbb_info
;
1394 bitmap_clear (&bb_info
->gen
);
1395 bitmap_clear (&bb_info
->kill
);
1396 bitmap_clear (&bb_info
->in
);
1397 bitmap_clear (&bb_info
->out
);
1398 pool_free (df_live
->block_pool
, bb_info
);
1403 /* Allocate or reset bitmaps for DF_LIVE blocks. The solution bits are
1404 not touched unless the block is new. */
1407 df_live_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
1409 unsigned int bb_index
;
1411 struct df_live_problem_data
*problem_data
;
1413 if (!df_live
->block_pool
)
1414 df_live
->block_pool
= create_alloc_pool ("df_live_block pool",
1415 sizeof (struct df_live_bb_info
), 100);
1416 if (df_live
->problem_data
)
1417 problem_data
= (struct df_live_problem_data
*) df_live
->problem_data
;
1420 problem_data
= XNEW (struct df_live_problem_data
);
1421 df_live
->problem_data
= problem_data
;
1423 problem_data
->out
= NULL
;
1424 problem_data
->in
= NULL
;
1425 bitmap_obstack_initialize (&problem_data
->live_bitmaps
);
1426 bitmap_initialize (&df_live_scratch
, &problem_data
->live_bitmaps
);
1429 df_grow_bb_info (df_live
);
1431 EXECUTE_IF_SET_IN_BITMAP (df_live
->out_of_date_transfer_functions
, 0, bb_index
, bi
)
1433 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb_index
);
1436 bitmap_clear (&bb_info
->kill
);
1437 bitmap_clear (&bb_info
->gen
);
1441 bb_info
= (struct df_live_bb_info
*) pool_alloc (df_live
->block_pool
);
1442 df_live_set_bb_info (bb_index
, bb_info
);
1443 bitmap_initialize (&bb_info
->kill
, &problem_data
->live_bitmaps
);
1444 bitmap_initialize (&bb_info
->gen
, &problem_data
->live_bitmaps
);
1445 bitmap_initialize (&bb_info
->in
, &problem_data
->live_bitmaps
);
1446 bitmap_initialize (&bb_info
->out
, &problem_data
->live_bitmaps
);
1449 df_live
->optional_p
= (optimize
<= 1);
1453 /* Reset the global solution for recalculation. */
1456 df_live_reset (bitmap all_blocks
)
1458 unsigned int bb_index
;
1461 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
1463 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb_index
);
1464 gcc_assert (bb_info
);
1465 bitmap_clear (&bb_info
->in
);
1466 bitmap_clear (&bb_info
->out
);
1471 /* Compute local uninitialized register info for basic block BB. */
1474 df_live_bb_local_compute (unsigned int bb_index
)
1476 basic_block bb
= BASIC_BLOCK (bb_index
);
1477 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb_index
);
1482 FOR_BB_INSNS (bb
, insn
)
1484 unsigned int uid
= INSN_UID (insn
);
1485 struct df_insn_info
*insn_info
= DF_INSN_UID_GET (uid
);
1487 /* Inserting labels does not always trigger the incremental
1491 gcc_assert (!INSN_P (insn
));
1492 insn_info
= df_insn_create_insn_record (insn
);
1495 DF_INSN_INFO_LUID (insn_info
) = luid
;
1500 for (def_rec
= DF_INSN_INFO_DEFS (insn_info
); *def_rec
; def_rec
++)
1502 df_ref def
= *def_rec
;
1503 unsigned int regno
= DF_REF_REGNO (def
);
1505 if (DF_REF_FLAGS_IS_SET (def
,
1506 DF_REF_PARTIAL
| DF_REF_CONDITIONAL
))
1507 /* All partial or conditional def
1508 seen are included in the gen set. */
1509 bitmap_set_bit (&bb_info
->gen
, regno
);
1510 else if (DF_REF_FLAGS_IS_SET (def
, DF_REF_MUST_CLOBBER
))
1511 /* Only must clobbers for the entire reg destroy the
1513 bitmap_set_bit (&bb_info
->kill
, regno
);
1514 else if (! DF_REF_FLAGS_IS_SET (def
, DF_REF_MAY_CLOBBER
))
1515 bitmap_set_bit (&bb_info
->gen
, regno
);
1519 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
1521 df_ref def
= *def_rec
;
1522 bitmap_set_bit (&bb_info
->gen
, DF_REF_REGNO (def
));
1527 /* Compute local uninitialized register info. */
1530 df_live_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED
)
1532 unsigned int bb_index
;
1535 df_grow_insn_info ();
1537 EXECUTE_IF_SET_IN_BITMAP (df_live
->out_of_date_transfer_functions
,
1540 df_live_bb_local_compute (bb_index
);
1543 bitmap_clear (df_live
->out_of_date_transfer_functions
);
1547 /* Initialize the solution vectors. */
1550 df_live_init (bitmap all_blocks
)
1552 unsigned int bb_index
;
1555 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
1557 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb_index
);
1558 struct df_lr_bb_info
*bb_lr_info
= df_lr_get_bb_info (bb_index
);
1560 /* No register may reach a location where it is not used. Thus
1561 we trim the rr result to the places where it is used. */
1562 bitmap_and (&bb_info
->out
, &bb_info
->gen
, &bb_lr_info
->out
);
1563 bitmap_clear (&bb_info
->in
);
1567 /* Forward confluence function that ignores fake edges. */
1570 df_live_confluence_n (edge e
)
1572 bitmap op1
= &df_live_get_bb_info (e
->dest
->index
)->in
;
1573 bitmap op2
= &df_live_get_bb_info (e
->src
->index
)->out
;
1575 if (e
->flags
& EDGE_FAKE
)
1578 bitmap_ior_into (op1
, op2
);
1582 /* Transfer function for the forwards must-initialized problem. */
1585 df_live_transfer_function (int bb_index
)
1587 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb_index
);
1588 struct df_lr_bb_info
*bb_lr_info
= df_lr_get_bb_info (bb_index
);
1589 bitmap in
= &bb_info
->in
;
1590 bitmap out
= &bb_info
->out
;
1591 bitmap gen
= &bb_info
->gen
;
1592 bitmap kill
= &bb_info
->kill
;
1594 /* We need to use a scratch set here so that the value returned from this
1595 function invocation properly reflects whether the sets changed in a
1596 significant way; i.e. not just because the lr set was anded in. */
1597 bitmap_and (&df_live_scratch
, gen
, &bb_lr_info
->out
);
1598 /* No register may reach a location where it is not used. Thus
1599 we trim the rr result to the places where it is used. */
1600 bitmap_and_into (in
, &bb_lr_info
->in
);
1602 return bitmap_ior_and_compl (out
, &df_live_scratch
, in
, kill
);
1606 /* And the LR info with the must-initialized registers, to produce the LIVE info. */
1609 df_live_finalize (bitmap all_blocks
)
1612 if (df_live
->solutions_dirty
)
1615 unsigned int bb_index
;
1617 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
1619 struct df_lr_bb_info
*bb_lr_info
= df_lr_get_bb_info (bb_index
);
1620 struct df_live_bb_info
*bb_live_info
= df_live_get_bb_info (bb_index
);
1622 /* No register may reach a location where it is not used. Thus
1623 we trim the rr result to the places where it is used. */
1624 bitmap_and_into (&bb_live_info
->in
, &bb_lr_info
->in
);
1625 bitmap_and_into (&bb_live_info
->out
, &bb_lr_info
->out
);
1628 df_live
->solutions_dirty
= false;
1633 /* Free all storage associated with the problem. */
1638 struct df_live_problem_data
*problem_data
1639 = (struct df_live_problem_data
*) df_live
->problem_data
;
1640 if (df_live
->block_info
)
1642 free_alloc_pool (df_live
->block_pool
);
1643 df_live
->block_info_size
= 0;
1644 free (df_live
->block_info
);
1645 bitmap_clear (&df_live_scratch
);
1646 bitmap_obstack_release (&problem_data
->live_bitmaps
);
1647 free (problem_data
);
1648 df_live
->problem_data
= NULL
;
1650 BITMAP_FREE (df_live
->out_of_date_transfer_functions
);
1655 /* Debugging info at top of bb. */
1658 df_live_top_dump (basic_block bb
, FILE *file
)
1660 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb
->index
);
1661 struct df_live_problem_data
*problem_data
;
1666 fprintf (file
, ";; live in \t");
1667 df_print_regset (file
, &bb_info
->in
);
1668 if (df_live
->problem_data
)
1670 problem_data
= (struct df_live_problem_data
*)df_live
->problem_data
;
1671 if (problem_data
->in
)
1673 fprintf (file
, ";; old in \t");
1674 df_print_regset (file
, &problem_data
->in
[bb
->index
]);
1677 fprintf (file
, ";; live gen \t");
1678 df_print_regset (file
, &bb_info
->gen
);
1679 fprintf (file
, ";; live kill\t");
1680 df_print_regset (file
, &bb_info
->kill
);
1684 /* Debugging info at bottom of bb. */
1687 df_live_bottom_dump (basic_block bb
, FILE *file
)
1689 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb
->index
);
1690 struct df_live_problem_data
*problem_data
;
1695 fprintf (file
, ";; live out \t");
1696 df_print_regset (file
, &bb_info
->out
);
1697 if (df_live
->problem_data
)
1699 problem_data
= (struct df_live_problem_data
*)df_live
->problem_data
;
1700 if (problem_data
->out
)
1702 fprintf (file
, ";; old out \t");
1703 df_print_regset (file
, &problem_data
->out
[bb
->index
]);
1709 /* Build the datastructure to verify that the solution to the dataflow
1710 equations is not dirty. */
1713 df_live_verify_solution_start (void)
1716 struct df_live_problem_data
*problem_data
;
1717 if (df_live
->solutions_dirty
)
1720 /* Set it true so that the solution is recomputed. */
1721 df_live
->solutions_dirty
= true;
1723 problem_data
= (struct df_live_problem_data
*)df_live
->problem_data
;
1724 problem_data
->in
= XNEWVEC (bitmap_head
, last_basic_block
);
1725 problem_data
->out
= XNEWVEC (bitmap_head
, last_basic_block
);
1729 bitmap_initialize (&problem_data
->in
[bb
->index
], &problem_data
->live_bitmaps
);
1730 bitmap_initialize (&problem_data
->out
[bb
->index
], &problem_data
->live_bitmaps
);
1731 bitmap_copy (&problem_data
->in
[bb
->index
], DF_LIVE_IN (bb
));
1732 bitmap_copy (&problem_data
->out
[bb
->index
], DF_LIVE_OUT (bb
));
1737 /* Compare the saved datastructure and the new solution to the dataflow
1741 df_live_verify_solution_end (void)
1743 struct df_live_problem_data
*problem_data
;
1746 problem_data
= (struct df_live_problem_data
*)df_live
->problem_data
;
1747 if (!problem_data
->out
)
1752 if ((!bitmap_equal_p (&problem_data
->in
[bb
->index
], DF_LIVE_IN (bb
)))
1753 || (!bitmap_equal_p (&problem_data
->out
[bb
->index
], DF_LIVE_OUT (bb
))))
1755 /*df_dump (stderr);*/
1760 /* Cannot delete them immediately because you may want to dump them
1761 if the comparison fails. */
1764 bitmap_clear (&problem_data
->in
[bb
->index
]);
1765 bitmap_clear (&problem_data
->out
[bb
->index
]);
1768 free (problem_data
->in
);
1769 free (problem_data
->out
);
1770 free (problem_data
);
1771 df_live
->problem_data
= NULL
;
1775 /* All of the information associated with every instance of the problem. */
1777 static struct df_problem problem_LIVE
=
1779 DF_LIVE
, /* Problem id. */
1780 DF_FORWARD
, /* Direction. */
1781 df_live_alloc
, /* Allocate the problem specific data. */
1782 df_live_reset
, /* Reset global information. */
1783 df_live_free_bb_info
, /* Free basic block info. */
1784 df_live_local_compute
, /* Local compute function. */
1785 df_live_init
, /* Init the solution specific data. */
1786 df_worklist_dataflow
, /* Worklist solver. */
1787 NULL
, /* Confluence operator 0. */
1788 df_live_confluence_n
, /* Confluence operator n. */
1789 df_live_transfer_function
, /* Transfer function. */
1790 df_live_finalize
, /* Finalize function. */
1791 df_live_free
, /* Free all of the problem information. */
1792 df_live_free
, /* Remove this problem from the stack of dataflow problems. */
1793 NULL
, /* Debugging. */
1794 df_live_top_dump
, /* Debugging start block. */
1795 df_live_bottom_dump
, /* Debugging end block. */
1796 df_live_verify_solution_start
,/* Incremental solution verify start. */
1797 df_live_verify_solution_end
, /* Incremental solution verify end. */
1798 &problem_LR
, /* Dependent problem. */
1799 TV_DF_LIVE
, /* Timing variable. */
1800 false /* Reset blocks on dropping out of blocks_to_analyze. */
1804 /* Create a new DATAFLOW instance and add it to an existing instance
1805 of DF. The returned structure is what is used to get at the
1809 df_live_add_problem (void)
1811 df_add_problem (&problem_LIVE
);
1812 /* These will be initialized when df_scan_blocks processes each
1814 df_live
->out_of_date_transfer_functions
= BITMAP_ALLOC (NULL
);
1818 /* Set all of the blocks as dirty. This needs to be done if this
1819 problem is added after all of the insns have been scanned. */
1822 df_live_set_all_dirty (void)
1826 bitmap_set_bit (df_live
->out_of_date_transfer_functions
,
1831 /* Verify that all of the lr related info is consistent and
1835 df_live_verify_transfer_functions (void)
1838 bitmap_head saved_gen
;
1839 bitmap_head saved_kill
;
1840 bitmap_head all_blocks
;
1845 bitmap_initialize (&saved_gen
, &bitmap_default_obstack
);
1846 bitmap_initialize (&saved_kill
, &bitmap_default_obstack
);
1847 bitmap_initialize (&all_blocks
, &bitmap_default_obstack
);
1849 df_grow_insn_info ();
1853 struct df_live_bb_info
*bb_info
= df_live_get_bb_info (bb
->index
);
1854 bitmap_set_bit (&all_blocks
, bb
->index
);
1858 /* Make a copy of the transfer functions and then compute
1859 new ones to see if the transfer functions have
1861 if (!bitmap_bit_p (df_live
->out_of_date_transfer_functions
,
1864 bitmap_copy (&saved_gen
, &bb_info
->gen
);
1865 bitmap_copy (&saved_kill
, &bb_info
->kill
);
1866 bitmap_clear (&bb_info
->gen
);
1867 bitmap_clear (&bb_info
->kill
);
1869 df_live_bb_local_compute (bb
->index
);
1870 gcc_assert (bitmap_equal_p (&saved_gen
, &bb_info
->gen
));
1871 gcc_assert (bitmap_equal_p (&saved_kill
, &bb_info
->kill
));
1876 /* If we do not have basic block info, the block must be in
1877 the list of dirty blocks or else some one has added a
1878 block behind our backs. */
1879 gcc_assert (bitmap_bit_p (df_live
->out_of_date_transfer_functions
,
1882 /* Make sure no one created a block without following
1884 gcc_assert (df_scan_get_bb_info (bb
->index
));
1887 /* Make sure there are no dirty bits in blocks that have been deleted. */
1888 gcc_assert (!bitmap_intersect_compl_p (df_live
->out_of_date_transfer_functions
,
1890 bitmap_clear (&saved_gen
);
1891 bitmap_clear (&saved_kill
);
1892 bitmap_clear (&all_blocks
);
1895 /*----------------------------------------------------------------------------
1896 CREATE DEF_USE (DU) and / or USE_DEF (UD) CHAINS
1898 Link either the defs to the uses and / or the uses to the defs.
1900 These problems are set up like the other dataflow problems so that
1901 they nicely fit into the framework. They are much simpler and only
1902 involve a single traversal of instructions and an examination of
1903 the reaching defs information (the dependent problem).
1904 ----------------------------------------------------------------------------*/
1906 #define df_chain_problem_p(FLAG) (((enum df_chain_flags)df_chain->local_flags)&(FLAG))
1908 /* Create a du or ud chain from SRC to DST and link it into SRC. */
1911 df_chain_create (df_ref src
, df_ref dst
)
1913 struct df_link
*head
= DF_REF_CHAIN (src
);
1914 struct df_link
*link
= (struct df_link
*) pool_alloc (df_chain
->block_pool
);
1916 DF_REF_CHAIN (src
) = link
;
1923 /* Delete any du or ud chains that start at REF and point to
1926 df_chain_unlink_1 (df_ref ref
, df_ref target
)
1928 struct df_link
*chain
= DF_REF_CHAIN (ref
);
1929 struct df_link
*prev
= NULL
;
1933 if (chain
->ref
== target
)
1936 prev
->next
= chain
->next
;
1938 DF_REF_CHAIN (ref
) = chain
->next
;
1939 pool_free (df_chain
->block_pool
, chain
);
1943 chain
= chain
->next
;
1948 /* Delete a du or ud chain that leave or point to REF. */
1951 df_chain_unlink (df_ref ref
)
1953 struct df_link
*chain
= DF_REF_CHAIN (ref
);
1956 struct df_link
*next
= chain
->next
;
1957 /* Delete the other side if it exists. */
1958 df_chain_unlink_1 (chain
->ref
, ref
);
1959 pool_free (df_chain
->block_pool
, chain
);
1962 DF_REF_CHAIN (ref
) = NULL
;
1966 /* Copy the du or ud chain starting at FROM_REF and attach it to
1970 df_chain_copy (df_ref to_ref
,
1971 struct df_link
*from_ref
)
1975 df_chain_create (to_ref
, from_ref
->ref
);
1976 from_ref
= from_ref
->next
;
1981 /* Remove this problem from the stack of dataflow problems. */
1984 df_chain_remove_problem (void)
1987 unsigned int bb_index
;
1989 /* Wholesale destruction of the old chains. */
1990 if (df_chain
->block_pool
)
1991 free_alloc_pool (df_chain
->block_pool
);
1993 EXECUTE_IF_SET_IN_BITMAP (df_chain
->out_of_date_transfer_functions
, 0, bb_index
, bi
)
1998 basic_block bb
= BASIC_BLOCK (bb_index
);
2000 if (df_chain_problem_p (DF_DU_CHAIN
))
2001 for (def_rec
= df_get_artificial_defs (bb
->index
); *def_rec
; def_rec
++)
2002 DF_REF_CHAIN (*def_rec
) = NULL
;
2003 if (df_chain_problem_p (DF_UD_CHAIN
))
2004 for (use_rec
= df_get_artificial_uses (bb
->index
); *use_rec
; use_rec
++)
2005 DF_REF_CHAIN (*use_rec
) = NULL
;
2007 FOR_BB_INSNS (bb
, insn
)
2009 unsigned int uid
= INSN_UID (insn
);
2013 if (df_chain_problem_p (DF_DU_CHAIN
))
2014 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
2015 DF_REF_CHAIN (*def_rec
) = NULL
;
2016 if (df_chain_problem_p (DF_UD_CHAIN
))
2018 for (use_rec
= DF_INSN_UID_USES (uid
); *use_rec
; use_rec
++)
2019 DF_REF_CHAIN (*use_rec
) = NULL
;
2020 for (use_rec
= DF_INSN_UID_EQ_USES (uid
); *use_rec
; use_rec
++)
2021 DF_REF_CHAIN (*use_rec
) = NULL
;
2027 bitmap_clear (df_chain
->out_of_date_transfer_functions
);
2028 df_chain
->block_pool
= NULL
;
2032 /* Remove the chain problem completely. */
2035 df_chain_fully_remove_problem (void)
2037 df_chain_remove_problem ();
2038 BITMAP_FREE (df_chain
->out_of_date_transfer_functions
);
2043 /* Create def-use or use-def chains. */
2046 df_chain_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
2048 df_chain_remove_problem ();
2049 df_chain
->block_pool
= create_alloc_pool ("df_chain_block pool",
2050 sizeof (struct df_link
), 50);
2051 df_chain
->optional_p
= true;
2055 /* Reset all of the chains when the set of basic blocks changes. */
2058 df_chain_reset (bitmap blocks_to_clear ATTRIBUTE_UNUSED
)
2060 df_chain_remove_problem ();
2064 /* Create the chains for a list of USEs. */
2067 df_chain_create_bb_process_use (bitmap local_rd
,
2072 unsigned int def_index
;
2076 df_ref use
= *use_rec
;
2077 unsigned int uregno
= DF_REF_REGNO (use
);
2078 if ((!(df
->changeable_flags
& DF_NO_HARD_REGS
))
2079 || (uregno
>= FIRST_PSEUDO_REGISTER
))
2081 /* Do not want to go through this for an uninitialized var. */
2082 int count
= DF_DEFS_COUNT (uregno
);
2085 if (top_flag
== (DF_REF_FLAGS (use
) & DF_REF_AT_TOP
))
2087 unsigned int first_index
= DF_DEFS_BEGIN (uregno
);
2088 unsigned int last_index
= first_index
+ count
- 1;
2090 EXECUTE_IF_SET_IN_BITMAP (local_rd
, first_index
, def_index
, bi
)
2093 if (def_index
> last_index
)
2096 def
= DF_DEFS_GET (def_index
);
2097 if (df_chain_problem_p (DF_DU_CHAIN
))
2098 df_chain_create (def
, use
);
2099 if (df_chain_problem_p (DF_UD_CHAIN
))
2100 df_chain_create (use
, def
);
2111 /* Create chains from reaching defs bitmaps for basic block BB. */
2114 df_chain_create_bb (unsigned int bb_index
)
2116 basic_block bb
= BASIC_BLOCK (bb_index
);
2117 struct df_rd_bb_info
*bb_info
= df_rd_get_bb_info (bb_index
);
2121 bitmap_initialize (&cpy
, &bitmap_default_obstack
);
2122 bitmap_copy (&cpy
, &bb_info
->in
);
2123 bitmap_set_bit (df_chain
->out_of_date_transfer_functions
, bb_index
);
2125 /* Since we are going forwards, process the artificial uses first
2126 then the artificial defs second. */
2129 /* Create the chains for the artificial uses from the EH_USES at the
2130 beginning of the block. */
2132 /* Artificials are only hard regs. */
2133 if (!(df
->changeable_flags
& DF_NO_HARD_REGS
))
2134 df_chain_create_bb_process_use (&cpy
,
2135 df_get_artificial_uses (bb
->index
),
2139 df_rd_simulate_artificial_defs_at_top (bb
, &cpy
);
2141 /* Process the regular instructions next. */
2142 FOR_BB_INSNS (bb
, insn
)
2145 unsigned int uid
= INSN_UID (insn
);
2147 /* First scan the uses and link them up with the defs that remain
2148 in the cpy vector. */
2149 df_chain_create_bb_process_use (&cpy
, DF_INSN_UID_USES (uid
), 0);
2150 if (df
->changeable_flags
& DF_EQ_NOTES
)
2151 df_chain_create_bb_process_use (&cpy
, DF_INSN_UID_EQ_USES (uid
), 0);
2153 /* Since we are going forwards, process the defs second. */
2154 df_rd_simulate_one_insn (bb
, insn
, &cpy
);
2157 /* Create the chains for the artificial uses of the hard registers
2158 at the end of the block. */
2159 if (!(df
->changeable_flags
& DF_NO_HARD_REGS
))
2160 df_chain_create_bb_process_use (&cpy
,
2161 df_get_artificial_uses (bb
->index
),
2164 bitmap_clear (&cpy
);
2167 /* Create def-use chains from reaching use bitmaps for basic blocks
2171 df_chain_finalize (bitmap all_blocks
)
2173 unsigned int bb_index
;
2176 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
2178 df_chain_create_bb (bb_index
);
2183 /* Free all storage associated with the problem. */
2186 df_chain_free (void)
2188 free_alloc_pool (df_chain
->block_pool
);
2189 BITMAP_FREE (df_chain
->out_of_date_transfer_functions
);
2194 /* Debugging info. */
2197 df_chain_top_dump (basic_block bb
, FILE *file
)
2199 if (df_chain_problem_p (DF_DU_CHAIN
))
2202 df_ref
*def_rec
= df_get_artificial_defs (bb
->index
);
2206 fprintf (file
, ";; DU chains for artificial defs\n");
2209 df_ref def
= *def_rec
;
2210 fprintf (file
, ";; reg %d ", DF_REF_REGNO (def
));
2211 df_chain_dump (DF_REF_CHAIN (def
), file
);
2212 fprintf (file
, "\n");
2217 FOR_BB_INSNS (bb
, insn
)
2221 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
2222 def_rec
= DF_INSN_INFO_DEFS (insn_info
);
2225 fprintf (file
, ";; DU chains for insn luid %d uid %d\n",
2226 DF_INSN_INFO_LUID (insn_info
), INSN_UID (insn
));
2230 df_ref def
= *def_rec
;
2231 fprintf (file
, ";; reg %d ", DF_REF_REGNO (def
));
2232 if (DF_REF_FLAGS (def
) & DF_REF_READ_WRITE
)
2233 fprintf (file
, "read/write ");
2234 df_chain_dump (DF_REF_CHAIN (def
), file
);
2235 fprintf (file
, "\n");
2246 df_chain_bottom_dump (basic_block bb
, FILE *file
)
2248 if (df_chain_problem_p (DF_UD_CHAIN
))
2251 df_ref
*use_rec
= df_get_artificial_uses (bb
->index
);
2255 fprintf (file
, ";; UD chains for artificial uses\n");
2258 df_ref use
= *use_rec
;
2259 fprintf (file
, ";; reg %d ", DF_REF_REGNO (use
));
2260 df_chain_dump (DF_REF_CHAIN (use
), file
);
2261 fprintf (file
, "\n");
2266 FOR_BB_INSNS (bb
, insn
)
2270 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
2271 df_ref
*eq_use_rec
= DF_INSN_INFO_EQ_USES (insn_info
);
2272 use_rec
= DF_INSN_INFO_USES (insn_info
);
2273 if (*use_rec
|| *eq_use_rec
)
2275 fprintf (file
, ";; UD chains for insn luid %d uid %d\n",
2276 DF_INSN_INFO_LUID (insn_info
), INSN_UID (insn
));
2280 df_ref use
= *use_rec
;
2281 fprintf (file
, ";; reg %d ", DF_REF_REGNO (use
));
2282 if (DF_REF_FLAGS (use
) & DF_REF_READ_WRITE
)
2283 fprintf (file
, "read/write ");
2284 df_chain_dump (DF_REF_CHAIN (use
), file
);
2285 fprintf (file
, "\n");
2290 df_ref use
= *eq_use_rec
;
2291 fprintf (file
, ";; eq_note reg %d ", DF_REF_REGNO (use
));
2292 df_chain_dump (DF_REF_CHAIN (use
), file
);
2293 fprintf (file
, "\n");
2303 static struct df_problem problem_CHAIN
=
2305 DF_CHAIN
, /* Problem id. */
2306 DF_NONE
, /* Direction. */
2307 df_chain_alloc
, /* Allocate the problem specific data. */
2308 df_chain_reset
, /* Reset global information. */
2309 NULL
, /* Free basic block info. */
2310 NULL
, /* Local compute function. */
2311 NULL
, /* Init the solution specific data. */
2312 NULL
, /* Iterative solver. */
2313 NULL
, /* Confluence operator 0. */
2314 NULL
, /* Confluence operator n. */
2315 NULL
, /* Transfer function. */
2316 df_chain_finalize
, /* Finalize function. */
2317 df_chain_free
, /* Free all of the problem information. */
2318 df_chain_fully_remove_problem
,/* Remove this problem from the stack of dataflow problems. */
2319 NULL
, /* Debugging. */
2320 df_chain_top_dump
, /* Debugging start block. */
2321 df_chain_bottom_dump
, /* Debugging end block. */
2322 NULL
, /* Incremental solution verify start. */
2323 NULL
, /* Incremental solution verify end. */
2324 &problem_RD
, /* Dependent problem. */
2325 TV_DF_CHAIN
, /* Timing variable. */
2326 false /* Reset blocks on dropping out of blocks_to_analyze. */
2330 /* Create a new DATAFLOW instance and add it to an existing instance
2331 of DF. The returned structure is what is used to get at the
2335 df_chain_add_problem (unsigned int chain_flags
)
2337 df_add_problem (&problem_CHAIN
);
2338 df_chain
->local_flags
= chain_flags
;
2339 df_chain
->out_of_date_transfer_functions
= BITMAP_ALLOC (NULL
);
2342 #undef df_chain_problem_p
2345 /*----------------------------------------------------------------------------
2346 BYTE LEVEL LIVE REGISTERS
2348 Find the locations in the function where any use of a pseudo can
2349 reach in the backwards direction. In and out bitvectors are built
2350 for each basic block. There are two mapping functions,
2351 df_byte_lr_get_regno_start and df_byte_lr_get_regno_len that are
2352 used to map regnos into bit vector positions.
2354 This problem differs from the regular df_lr function in the way
2355 that subregs, *_extracts and strict_low_parts are handled. In lr
2356 these are consider partial kills, here, the exact set of bytes is
2357 modeled. Note that any reg that has none of these operations is
2358 only modeled with a single bit since all operations access the
2361 This problem is more brittle that the regular lr. It currently can
2362 be used in dce incrementally, but cannot be used in an environment
2363 where insns are created or modified. The problem is that the
2364 mapping of regnos to bitmap positions is relatively compact, in
2365 that if a pseudo does not do any of the byte wise operations, only
2366 one slot is allocated, rather than a slot for each byte. If insn
2367 are created, where a subreg is used for a reg that had no subregs,
2368 the mapping would be wrong. Likewise, there are no checks to see
2369 that new pseudos have been added. These issues could be addressed
2370 by adding a problem specific flag to not use the compact mapping,
2371 if there was a need to do so.
2373 ----------------------------------------------------------------------------*/
2375 /* Private data used to verify the solution for this problem. */
2376 struct df_byte_lr_problem_data
2378 /* Expanded versions of bitvectors used in lr. */
2379 bitmap_head invalidated_by_call
;
2380 bitmap_head hardware_regs_used
;
2382 /* Indexed by regno, this is true if there are subregs, extracts or
2383 strict_low_parts for this regno. */
2384 bitmap_head needs_expansion
;
2386 /* The start position and len for each regno in the various bit
2388 unsigned int* regno_start
;
2389 unsigned int* regno_len
;
2390 /* An obstack for the bitmaps we need for this problem. */
2391 bitmap_obstack byte_lr_bitmaps
;
2395 /* Get the starting location for REGNO in the df_byte_lr bitmaps. */
2398 df_byte_lr_get_regno_start (unsigned int regno
)
2400 struct df_byte_lr_problem_data
*problem_data
2401 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;;
2402 return problem_data
->regno_start
[regno
];
2406 /* Get the len for REGNO in the df_byte_lr bitmaps. */
2409 df_byte_lr_get_regno_len (unsigned int regno
)
2411 struct df_byte_lr_problem_data
*problem_data
2412 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;;
2413 return problem_data
->regno_len
[regno
];
2417 /* Set basic block info. */
2420 df_byte_lr_set_bb_info (unsigned int index
,
2421 struct df_byte_lr_bb_info
*bb_info
)
2423 gcc_assert (df_byte_lr
);
2424 gcc_assert (index
< df_byte_lr
->block_info_size
);
2425 df_byte_lr
->block_info
[index
] = bb_info
;
2429 /* Free basic block info. */
2432 df_byte_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED
,
2435 struct df_byte_lr_bb_info
*bb_info
= (struct df_byte_lr_bb_info
*) vbb_info
;
2438 bitmap_clear (&bb_info
->use
);
2439 bitmap_clear (&bb_info
->def
);
2440 bitmap_clear (&bb_info
->in
);
2441 bitmap_clear (&bb_info
->out
);
2442 pool_free (df_byte_lr
->block_pool
, bb_info
);
2447 /* Check all of the refs in REF_REC to see if any of them are
2448 extracts, subregs or strict_low_parts. */
2451 df_byte_lr_check_regs (df_ref
*ref_rec
)
2453 struct df_byte_lr_problem_data
*problem_data
2454 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2456 for (; *ref_rec
; ref_rec
++)
2458 df_ref ref
= *ref_rec
;
2459 if (DF_REF_FLAGS_IS_SET (ref
, DF_REF_SIGN_EXTRACT
2460 | DF_REF_ZERO_EXTRACT
2461 | DF_REF_STRICT_LOW_PART
)
2462 || GET_CODE (DF_REF_REG (ref
)) == SUBREG
)
2463 bitmap_set_bit (&problem_data
->needs_expansion
, DF_REF_REGNO (ref
));
2468 /* Expand bitmap SRC which is indexed by regno to DEST which is indexed by
2469 regno_start and regno_len. */
2472 df_byte_lr_expand_bitmap (bitmap dest
, bitmap src
)
2474 struct df_byte_lr_problem_data
*problem_data
2475 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2479 bitmap_clear (dest
);
2480 EXECUTE_IF_SET_IN_BITMAP (src
, 0, i
, bi
)
2482 bitmap_set_range (dest
, problem_data
->regno_start
[i
],
2483 problem_data
->regno_len
[i
]);
2488 /* Allocate or reset bitmaps for DF_BYTE_LR blocks. The solution bits are
2489 not touched unless the block is new. */
2492 df_byte_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
2494 unsigned int bb_index
;
2498 unsigned int index
= 0;
2499 unsigned int max_reg
= max_reg_num();
2500 struct df_byte_lr_problem_data
*problem_data
2501 = XNEW (struct df_byte_lr_problem_data
);
2503 df_byte_lr
->problem_data
= problem_data
;
2505 if (!df_byte_lr
->block_pool
)
2506 df_byte_lr
->block_pool
= create_alloc_pool ("df_byte_lr_block pool",
2507 sizeof (struct df_byte_lr_bb_info
), 50);
2509 df_grow_bb_info (df_byte_lr
);
2511 /* Create the mapping from regnos to slots. This does not change
2512 unless the problem is destroyed and recreated. In particular, if
2513 we end up deleting the only insn that used a subreg, we do not
2514 want to redo the mapping because this would invalidate everything
2517 bitmap_obstack_initialize (&problem_data
->byte_lr_bitmaps
);
2518 problem_data
->regno_start
= XNEWVEC (unsigned int, max_reg
);
2519 problem_data
->regno_len
= XNEWVEC (unsigned int, max_reg
);
2520 bitmap_initialize (&problem_data
->hardware_regs_used
,
2521 &problem_data
->byte_lr_bitmaps
);
2522 bitmap_initialize (&problem_data
->invalidated_by_call
,
2523 &problem_data
->byte_lr_bitmaps
);
2524 bitmap_initialize (&problem_data
->needs_expansion
,
2525 &problem_data
->byte_lr_bitmaps
);
2527 /* Discover which regno's use subregs, extracts or
2528 strict_low_parts. */
2532 FOR_BB_INSNS (bb
, insn
)
2536 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
2537 df_byte_lr_check_regs (DF_INSN_INFO_DEFS (insn_info
));
2538 df_byte_lr_check_regs (DF_INSN_INFO_USES (insn_info
));
2541 bitmap_set_bit (df_byte_lr
->out_of_date_transfer_functions
, bb
->index
);
2544 bitmap_set_bit (df_byte_lr
->out_of_date_transfer_functions
, ENTRY_BLOCK
);
2545 bitmap_set_bit (df_byte_lr
->out_of_date_transfer_functions
, EXIT_BLOCK
);
2547 /* Allocate the slots for each regno. */
2548 for (regno
= 0; regno
< max_reg
; regno
++)
2551 problem_data
->regno_start
[regno
] = index
;
2552 if (bitmap_bit_p (&problem_data
->needs_expansion
, regno
))
2553 len
= GET_MODE_SIZE (GET_MODE (regno_reg_rtx
[regno
]));
2557 problem_data
->regno_len
[regno
] = len
;
2561 df_byte_lr_expand_bitmap (&problem_data
->hardware_regs_used
,
2562 &df
->hardware_regs_used
);
2563 df_byte_lr_expand_bitmap (&problem_data
->invalidated_by_call
,
2564 regs_invalidated_by_call_regset
);
2566 EXECUTE_IF_SET_IN_BITMAP (df_byte_lr
->out_of_date_transfer_functions
, 0, bb_index
, bi
)
2568 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb_index
);
2571 bitmap_clear (&bb_info
->def
);
2572 bitmap_clear (&bb_info
->use
);
2576 bb_info
= (struct df_byte_lr_bb_info
*) pool_alloc (df_byte_lr
->block_pool
);
2577 df_byte_lr_set_bb_info (bb_index
, bb_info
);
2578 bitmap_initialize (&bb_info
->use
, &problem_data
->byte_lr_bitmaps
);
2579 bitmap_initialize (&bb_info
->def
, &problem_data
->byte_lr_bitmaps
);
2580 bitmap_initialize (&bb_info
->in
, &problem_data
->byte_lr_bitmaps
);
2581 bitmap_initialize (&bb_info
->out
, &problem_data
->byte_lr_bitmaps
);
2585 df_byte_lr
->optional_p
= true;
2589 /* Reset the global solution for recalculation. */
2592 df_byte_lr_reset (bitmap all_blocks
)
2594 unsigned int bb_index
;
2597 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
2599 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb_index
);
2600 gcc_assert (bb_info
);
2601 bitmap_clear (&bb_info
->in
);
2602 bitmap_clear (&bb_info
->out
);
2607 /* Compute local live register info for basic block BB. */
2610 df_byte_lr_bb_local_compute (unsigned int bb_index
)
2612 struct df_byte_lr_problem_data
*problem_data
2613 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2614 basic_block bb
= BASIC_BLOCK (bb_index
);
2615 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb_index
);
2620 /* Process the registers set in an exception handler. */
2621 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
2623 df_ref def
= *def_rec
;
2624 if ((DF_REF_FLAGS (def
) & DF_REF_AT_TOP
) == 0)
2626 unsigned int dregno
= DF_REF_REGNO (def
);
2627 unsigned int start
= problem_data
->regno_start
[dregno
];
2628 unsigned int len
= problem_data
->regno_len
[dregno
];
2629 bitmap_set_range (&bb_info
->def
, start
, len
);
2630 bitmap_clear_range (&bb_info
->use
, start
, len
);
2634 /* Process the hardware registers that are always live. */
2635 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
2637 df_ref use
= *use_rec
;
2638 /* Add use to set of uses in this BB. */
2639 if ((DF_REF_FLAGS (use
) & DF_REF_AT_TOP
) == 0)
2641 unsigned int uregno
= DF_REF_REGNO (use
);
2642 unsigned int start
= problem_data
->regno_start
[uregno
];
2643 unsigned int len
= problem_data
->regno_len
[uregno
];
2644 bitmap_set_range (&bb_info
->use
, start
, len
);
2648 FOR_BB_INSNS_REVERSE (bb
, insn
)
2650 unsigned int uid
= INSN_UID (insn
);
2655 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
2657 df_ref def
= *def_rec
;
2658 /* If the def is to only part of the reg, it does
2659 not kill the other defs that reach here. */
2660 if (!(DF_REF_FLAGS (def
) & (DF_REF_CONDITIONAL
)))
2662 unsigned int dregno
= DF_REF_REGNO (def
);
2663 unsigned int start
= problem_data
->regno_start
[dregno
];
2664 unsigned int len
= problem_data
->regno_len
[dregno
];
2667 if (!df_compute_accessed_bytes (def
, DF_MM_MUST
, &sb
, &lb
))
2674 bitmap_set_range (&bb_info
->def
, start
, len
);
2675 bitmap_clear_range (&bb_info
->use
, start
, len
);
2680 for (use_rec
= DF_INSN_UID_USES (uid
); *use_rec
; use_rec
++)
2682 df_ref use
= *use_rec
;
2683 unsigned int uregno
= DF_REF_REGNO (use
);
2684 unsigned int start
= problem_data
->regno_start
[uregno
];
2685 unsigned int len
= problem_data
->regno_len
[uregno
];
2688 if (!df_compute_accessed_bytes (use
, DF_MM_MAY
, &sb
, &lb
))
2693 /* Add use to set of uses in this BB. */
2695 bitmap_set_range (&bb_info
->use
, start
, len
);
2699 /* Process the registers set in an exception handler or the hard
2700 frame pointer if this block is the target of a non local
2702 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
2704 df_ref def
= *def_rec
;
2705 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
2707 unsigned int dregno
= DF_REF_REGNO (def
);
2708 unsigned int start
= problem_data
->regno_start
[dregno
];
2709 unsigned int len
= problem_data
->regno_len
[dregno
];
2710 bitmap_set_range (&bb_info
->def
, start
, len
);
2711 bitmap_clear_range (&bb_info
->use
, start
, len
);
2716 /* Process the uses that are live into an exception handler. */
2717 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
2719 df_ref use
= *use_rec
;
2720 /* Add use to set of uses in this BB. */
2721 if (DF_REF_FLAGS (use
) & DF_REF_AT_TOP
)
2723 unsigned int uregno
= DF_REF_REGNO (use
);
2724 unsigned int start
= problem_data
->regno_start
[uregno
];
2725 unsigned int len
= problem_data
->regno_len
[uregno
];
2726 bitmap_set_range (&bb_info
->use
, start
, len
);
2733 /* Compute local live register info for each basic block within BLOCKS. */
2736 df_byte_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED
)
2738 unsigned int bb_index
;
2741 EXECUTE_IF_SET_IN_BITMAP (df_byte_lr
->out_of_date_transfer_functions
, 0, bb_index
, bi
)
2743 if (bb_index
== EXIT_BLOCK
)
2745 /* The exit block is special for this problem and its bits are
2746 computed from thin air. */
2747 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (EXIT_BLOCK
);
2748 df_byte_lr_expand_bitmap (&bb_info
->use
, df
->exit_block_uses
);
2751 df_byte_lr_bb_local_compute (bb_index
);
2754 bitmap_clear (df_byte_lr
->out_of_date_transfer_functions
);
2758 /* Initialize the solution vectors. */
2761 df_byte_lr_init (bitmap all_blocks
)
2763 unsigned int bb_index
;
2766 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
2768 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb_index
);
2769 bitmap_copy (&bb_info
->in
, &bb_info
->use
);
2770 bitmap_clear (&bb_info
->out
);
2775 /* Confluence function that processes infinite loops. This might be a
2776 noreturn function that throws. And even if it isn't, getting the
2777 unwind info right helps debugging. */
2779 df_byte_lr_confluence_0 (basic_block bb
)
2781 struct df_byte_lr_problem_data
*problem_data
2782 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2783 bitmap op1
= &df_byte_lr_get_bb_info (bb
->index
)->out
;
2784 if (bb
!= EXIT_BLOCK_PTR
)
2785 bitmap_copy (op1
, &problem_data
->hardware_regs_used
);
2789 /* Confluence function that ignores fake edges. */
2792 df_byte_lr_confluence_n (edge e
)
2794 struct df_byte_lr_problem_data
*problem_data
2795 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2796 bitmap op1
= &df_byte_lr_get_bb_info (e
->src
->index
)->out
;
2797 bitmap op2
= &df_byte_lr_get_bb_info (e
->dest
->index
)->in
;
2799 /* Call-clobbered registers die across exception and call edges. */
2800 /* ??? Abnormal call edges ignored for the moment, as this gets
2801 confused by sibling call edges, which crashes reg-stack. */
2802 if (e
->flags
& EDGE_EH
)
2803 bitmap_ior_and_compl_into (op1
, op2
, &problem_data
->invalidated_by_call
);
2805 bitmap_ior_into (op1
, op2
);
2807 bitmap_ior_into (op1
, &problem_data
->hardware_regs_used
);
2811 /* Transfer function. */
2814 df_byte_lr_transfer_function (int bb_index
)
2816 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb_index
);
2817 bitmap in
= &bb_info
->in
;
2818 bitmap out
= &bb_info
->out
;
2819 bitmap use
= &bb_info
->use
;
2820 bitmap def
= &bb_info
->def
;
2822 return bitmap_ior_and_compl (in
, use
, out
, def
);
2826 /* Free all storage associated with the problem. */
2829 df_byte_lr_free (void)
2831 struct df_byte_lr_problem_data
*problem_data
2832 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2835 if (df_byte_lr
->block_info
)
2837 free_alloc_pool (df_byte_lr
->block_pool
);
2838 df_byte_lr
->block_info_size
= 0;
2839 free (df_byte_lr
->block_info
);
2842 BITMAP_FREE (df_byte_lr
->out_of_date_transfer_functions
);
2843 bitmap_obstack_release (&problem_data
->byte_lr_bitmaps
);
2844 free (problem_data
->regno_start
);
2845 free (problem_data
->regno_len
);
2846 free (problem_data
);
2851 /* Debugging info at top of bb. */
2854 df_byte_lr_top_dump (basic_block bb
, FILE *file
)
2856 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb
->index
);
2860 fprintf (file
, ";; blr in \t");
2861 df_print_byte_regset (file
, &bb_info
->in
);
2862 fprintf (file
, ";; blr use \t");
2863 df_print_byte_regset (file
, &bb_info
->use
);
2864 fprintf (file
, ";; blr def \t");
2865 df_print_byte_regset (file
, &bb_info
->def
);
2869 /* Debugging info at bottom of bb. */
2872 df_byte_lr_bottom_dump (basic_block bb
, FILE *file
)
2874 struct df_byte_lr_bb_info
*bb_info
= df_byte_lr_get_bb_info (bb
->index
);
2878 fprintf (file
, ";; blr out \t");
2879 df_print_byte_regset (file
, &bb_info
->out
);
2883 /* All of the information associated with every instance of the problem. */
2885 static struct df_problem problem_BYTE_LR
=
2887 DF_BYTE_LR
, /* Problem id. */
2888 DF_BACKWARD
, /* Direction. */
2889 df_byte_lr_alloc
, /* Allocate the problem specific data. */
2890 df_byte_lr_reset
, /* Reset global information. */
2891 df_byte_lr_free_bb_info
, /* Free basic block info. */
2892 df_byte_lr_local_compute
, /* Local compute function. */
2893 df_byte_lr_init
, /* Init the solution specific data. */
2894 df_worklist_dataflow
, /* Worklist solver. */
2895 df_byte_lr_confluence_0
, /* Confluence operator 0. */
2896 df_byte_lr_confluence_n
, /* Confluence operator n. */
2897 df_byte_lr_transfer_function
, /* Transfer function. */
2898 NULL
, /* Finalize function. */
2899 df_byte_lr_free
, /* Free all of the problem information. */
2900 df_byte_lr_free
, /* Remove this problem from the stack of dataflow problems. */
2901 NULL
, /* Debugging. */
2902 df_byte_lr_top_dump
, /* Debugging start block. */
2903 df_byte_lr_bottom_dump
, /* Debugging end block. */
2904 NULL
, /* Incremental solution verify start. */
2905 NULL
, /* Incremental solution verify end. */
2906 NULL
, /* Dependent problem. */
2907 TV_DF_BYTE_LR
, /* Timing variable. */
2908 false /* Reset blocks on dropping out of blocks_to_analyze. */
2912 /* Create a new DATAFLOW instance and add it to an existing instance
2913 of DF. The returned structure is what is used to get at the
2917 df_byte_lr_add_problem (void)
2919 df_add_problem (&problem_BYTE_LR
);
2920 /* These will be initialized when df_scan_blocks processes each
2922 df_byte_lr
->out_of_date_transfer_functions
= BITMAP_ALLOC (NULL
);
2926 /* Simulate the effects of the defs of INSN on LIVE. */
2929 df_byte_lr_simulate_defs (rtx insn
, bitmap live
)
2931 struct df_byte_lr_problem_data
*problem_data
2932 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2934 unsigned int uid
= INSN_UID (insn
);
2936 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
2938 df_ref def
= *def_rec
;
2940 /* If the def is to only part of the reg, it does
2941 not kill the other defs that reach here. */
2942 if (!(DF_REF_FLAGS (def
) & DF_REF_CONDITIONAL
))
2944 unsigned int dregno
= DF_REF_REGNO (def
);
2945 unsigned int start
= problem_data
->regno_start
[dregno
];
2946 unsigned int len
= problem_data
->regno_len
[dregno
];
2949 if (!df_compute_accessed_bytes (def
, DF_MM_MUST
, &sb
, &lb
))
2956 bitmap_clear_range (live
, start
, len
);
2962 /* Simulate the effects of the uses of INSN on LIVE. */
2965 df_byte_lr_simulate_uses (rtx insn
, bitmap live
)
2967 struct df_byte_lr_problem_data
*problem_data
2968 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
2970 unsigned int uid
= INSN_UID (insn
);
2972 for (use_rec
= DF_INSN_UID_USES (uid
); *use_rec
; use_rec
++)
2974 df_ref use
= *use_rec
;
2975 unsigned int uregno
= DF_REF_REGNO (use
);
2976 unsigned int start
= problem_data
->regno_start
[uregno
];
2977 unsigned int len
= problem_data
->regno_len
[uregno
];
2981 if (!df_compute_accessed_bytes (use
, DF_MM_MAY
, &sb
, &lb
))
2987 /* Add use to set of uses in this BB. */
2989 bitmap_set_range (live
, start
, len
);
2994 /* Apply the artificial uses and defs at the top of BB in a forwards
2998 df_byte_lr_simulate_artificial_refs_at_top (basic_block bb
, bitmap live
)
3000 struct df_byte_lr_problem_data
*problem_data
3001 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
3006 int bb_index
= bb
->index
;
3009 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
3011 df_ref use
= *use_rec
;
3012 if (DF_REF_FLAGS (use
) & DF_REF_AT_TOP
)
3014 unsigned int uregno
= DF_REF_REGNO (use
);
3015 unsigned int start
= problem_data
->regno_start
[uregno
];
3016 unsigned int len
= problem_data
->regno_len
[uregno
];
3017 bitmap_set_range (live
, start
, len
);
3022 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
3024 df_ref def
= *def_rec
;
3025 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
3027 unsigned int dregno
= DF_REF_REGNO (def
);
3028 unsigned int start
= problem_data
->regno_start
[dregno
];
3029 unsigned int len
= problem_data
->regno_len
[dregno
];
3030 bitmap_clear_range (live
, start
, len
);
3036 /* Apply the artificial uses and defs at the end of BB in a backwards
3040 df_byte_lr_simulate_artificial_refs_at_end (basic_block bb
, bitmap live
)
3042 struct df_byte_lr_problem_data
*problem_data
3043 = (struct df_byte_lr_problem_data
*)df_byte_lr
->problem_data
;
3046 int bb_index
= bb
->index
;
3048 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
3050 df_ref def
= *def_rec
;
3051 if ((DF_REF_FLAGS (def
) & DF_REF_AT_TOP
) == 0)
3053 unsigned int dregno
= DF_REF_REGNO (def
);
3054 unsigned int start
= problem_data
->regno_start
[dregno
];
3055 unsigned int len
= problem_data
->regno_len
[dregno
];
3056 bitmap_clear_range (live
, start
, len
);
3060 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
3062 df_ref use
= *use_rec
;
3063 if ((DF_REF_FLAGS (use
) & DF_REF_AT_TOP
) == 0)
3065 unsigned int uregno
= DF_REF_REGNO (use
);
3066 unsigned int start
= problem_data
->regno_start
[uregno
];
3067 unsigned int len
= problem_data
->regno_len
[uregno
];
3068 bitmap_set_range (live
, start
, len
);
3075 /*----------------------------------------------------------------------------
3076 This problem computes REG_DEAD and REG_UNUSED notes.
3077 ----------------------------------------------------------------------------*/
3080 df_note_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
3082 df_note
->optional_p
= true;
3085 #ifdef REG_DEAD_DEBUGGING
3087 df_print_note (const char *prefix
, rtx insn
, rtx note
)
3091 fprintf (dump_file
, "%s %d ", prefix
, INSN_UID (insn
));
3092 print_rtl (dump_file
, note
);
3093 fprintf (dump_file
, "\n");
3099 /* After reg-stack, the x86 floating point stack regs are difficult to
3100 analyze because of all of the pushes, pops and rotations. Thus, we
3101 just leave the notes alone. */
3105 df_ignore_stack_reg (int regno
)
3107 return regstack_completed
3108 && IN_RANGE (regno
, FIRST_STACK_REG
, LAST_STACK_REG
);
3112 df_ignore_stack_reg (int regno ATTRIBUTE_UNUSED
)
3119 /* Remove all of the REG_DEAD or REG_UNUSED notes from INSN and add
3120 them to OLD_DEAD_NOTES and OLD_UNUSED_NOTES. */
3123 df_kill_notes (rtx insn
, rtx
*old_dead_notes
, rtx
*old_unused_notes
)
3125 rtx
*pprev
= ®_NOTES (insn
);
3132 switch (REG_NOTE_KIND (link
))
3135 /* After reg-stack, we need to ignore any unused notes
3136 for the stack registers. */
3137 if (df_ignore_stack_reg (REGNO (XEXP (link
, 0))))
3139 pprev
= &XEXP (link
, 1);
3144 rtx next
= XEXP (link
, 1);
3145 #ifdef REG_DEAD_DEBUGGING
3146 df_print_note ("deleting: ", insn
, link
);
3148 XEXP (link
, 1) = dead
;
3150 *pprev
= link
= next
;
3155 /* After reg-stack, we need to ignore any unused notes
3156 for the stack registers. */
3157 if (df_ignore_stack_reg (REGNO (XEXP (link
, 0))))
3159 pprev
= &XEXP (link
, 1);
3164 rtx next
= XEXP (link
, 1);
3165 #ifdef REG_DEAD_DEBUGGING
3166 df_print_note ("deleting: ", insn
, link
);
3168 XEXP (link
, 1) = unused
;
3170 *pprev
= link
= next
;
3175 pprev
= &XEXP (link
, 1);
3181 *old_dead_notes
= dead
;
3182 *old_unused_notes
= unused
;
3186 /* Set a NOTE_TYPE note for REG in INSN. Try to pull it from the OLD
3187 list, otherwise create a new one. */
3190 df_set_note (enum reg_note note_type
, rtx insn
, rtx old
, rtx reg
)
3195 gcc_assert (!DEBUG_INSN_P (insn
));
3198 if (XEXP (curr
, 0) == reg
)
3201 XEXP (prev
, 1) = XEXP (curr
, 1);
3203 old
= XEXP (curr
, 1);
3204 XEXP (curr
, 1) = REG_NOTES (insn
);
3205 REG_NOTES (insn
) = curr
;
3211 curr
= XEXP (curr
, 1);
3214 /* Did not find the note. */
3215 add_reg_note (insn
, note_type
, reg
);
3219 /* A subroutine of df_set_unused_notes_for_mw, with a selection of its
3220 arguments. Return true if the register value described by MWS's
3221 mw_reg is known to be completely unused, and if mw_reg can therefore
3222 be used in a REG_UNUSED note. */
3225 df_whole_mw_reg_unused_p (struct df_mw_hardreg
*mws
,
3226 bitmap live
, bitmap artificial_uses
)
3230 /* If MWS describes a partial reference, create REG_UNUSED notes for
3231 individual hard registers. */
3232 if (mws
->flags
& DF_REF_PARTIAL
)
3235 /* Likewise if some part of the register is used. */
3236 for (r
= mws
->start_regno
; r
<= mws
->end_regno
; r
++)
3237 if (bitmap_bit_p (live
, r
)
3238 || bitmap_bit_p (artificial_uses
, r
))
3241 gcc_assert (REG_P (mws
->mw_reg
));
3245 /* Set the REG_UNUSED notes for the multiword hardreg defs in INSN
3246 based on the bits in LIVE. Do not generate notes for registers in
3247 artificial uses. DO_NOT_GEN is updated so that REG_DEAD notes are
3248 not generated if the reg is both read and written by the
3253 df_set_unused_notes_for_mw (rtx insn
, rtx old
, struct df_mw_hardreg
*mws
,
3254 bitmap live
, bitmap do_not_gen
,
3255 bitmap artificial_uses
)
3259 #ifdef REG_DEAD_DEBUGGING
3261 fprintf (dump_file
, "mw_set_unused looking at mws[%d..%d]\n",
3262 mws
->start_regno
, mws
->end_regno
);
3265 if (df_whole_mw_reg_unused_p (mws
, live
, artificial_uses
))
3267 unsigned int regno
= mws
->start_regno
;
3268 old
= df_set_note (REG_UNUSED
, insn
, old
, mws
->mw_reg
);
3270 #ifdef REG_DEAD_DEBUGGING
3271 df_print_note ("adding 1: ", insn
, REG_NOTES (insn
));
3273 bitmap_set_bit (do_not_gen
, regno
);
3274 /* Only do this if the value is totally dead. */
3277 for (r
= mws
->start_regno
; r
<= mws
->end_regno
; r
++)
3279 if (!bitmap_bit_p (live
, r
)
3280 && !bitmap_bit_p (artificial_uses
, r
))
3282 old
= df_set_note (REG_UNUSED
, insn
, old
, regno_reg_rtx
[r
]);
3283 #ifdef REG_DEAD_DEBUGGING
3284 df_print_note ("adding 2: ", insn
, REG_NOTES (insn
));
3287 bitmap_set_bit (do_not_gen
, r
);
3293 /* A subroutine of df_set_dead_notes_for_mw, with a selection of its
3294 arguments. Return true if the register value described by MWS's
3295 mw_reg is known to be completely dead, and if mw_reg can therefore
3296 be used in a REG_DEAD note. */
3299 df_whole_mw_reg_dead_p (struct df_mw_hardreg
*mws
,
3300 bitmap live
, bitmap artificial_uses
,
3305 /* If MWS describes a partial reference, create REG_DEAD notes for
3306 individual hard registers. */
3307 if (mws
->flags
& DF_REF_PARTIAL
)
3310 /* Likewise if some part of the register is not dead. */
3311 for (r
= mws
->start_regno
; r
<= mws
->end_regno
; r
++)
3312 if (bitmap_bit_p (live
, r
)
3313 || bitmap_bit_p (artificial_uses
, r
)
3314 || bitmap_bit_p (do_not_gen
, r
))
3317 gcc_assert (REG_P (mws
->mw_reg
));
3321 /* Set the REG_DEAD notes for the multiword hardreg use in INSN based
3322 on the bits in LIVE. DO_NOT_GEN is used to keep REG_DEAD notes
3323 from being set if the instruction both reads and writes the
3327 df_set_dead_notes_for_mw (rtx insn
, rtx old
, struct df_mw_hardreg
*mws
,
3328 bitmap live
, bitmap do_not_gen
,
3329 bitmap artificial_uses
, bool *added_notes_p
)
3332 bool is_debug
= *added_notes_p
;
3334 *added_notes_p
= false;
3336 #ifdef REG_DEAD_DEBUGGING
3339 fprintf (dump_file
, "mw_set_dead looking at mws[%d..%d]\n do_not_gen =",
3340 mws
->start_regno
, mws
->end_regno
);
3341 df_print_regset (dump_file
, do_not_gen
);
3342 fprintf (dump_file
, " live =");
3343 df_print_regset (dump_file
, live
);
3344 fprintf (dump_file
, " artificial uses =");
3345 df_print_regset (dump_file
, artificial_uses
);
3349 if (df_whole_mw_reg_dead_p (mws
, live
, artificial_uses
, do_not_gen
))
3351 /* Add a dead note for the entire multi word register. */
3354 *added_notes_p
= true;
3357 old
= df_set_note (REG_DEAD
, insn
, old
, mws
->mw_reg
);
3358 #ifdef REG_DEAD_DEBUGGING
3359 df_print_note ("adding 1: ", insn
, REG_NOTES (insn
));
3364 for (r
= mws
->start_regno
; r
<= mws
->end_regno
; r
++)
3365 if (!bitmap_bit_p (live
, r
)
3366 && !bitmap_bit_p (artificial_uses
, r
)
3367 && !bitmap_bit_p (do_not_gen
, r
))
3371 *added_notes_p
= true;
3374 old
= df_set_note (REG_DEAD
, insn
, old
, regno_reg_rtx
[r
]);
3375 #ifdef REG_DEAD_DEBUGGING
3376 df_print_note ("adding 2: ", insn
, REG_NOTES (insn
));
3384 /* Create a REG_UNUSED note if necessary for DEF in INSN updating
3385 LIVE. Do not generate notes for registers in ARTIFICIAL_USES. */
3388 df_create_unused_note (rtx insn
, rtx old
, df_ref def
,
3389 bitmap live
, bitmap artificial_uses
)
3391 unsigned int dregno
= DF_REF_REGNO (def
);
3393 #ifdef REG_DEAD_DEBUGGING
3396 fprintf (dump_file
, " regular looking at def ");
3397 df_ref_debug (def
, dump_file
);
3401 if (!((DF_REF_FLAGS (def
) & DF_REF_MW_HARDREG
)
3402 || bitmap_bit_p (live
, dregno
)
3403 || bitmap_bit_p (artificial_uses
, dregno
)
3404 || df_ignore_stack_reg (dregno
)))
3406 rtx reg
= (DF_REF_LOC (def
))
3407 ? *DF_REF_REAL_LOC (def
): DF_REF_REG (def
);
3408 old
= df_set_note (REG_UNUSED
, insn
, old
, reg
);
3409 #ifdef REG_DEAD_DEBUGGING
3410 df_print_note ("adding 3: ", insn
, REG_NOTES (insn
));
3417 /* Node of a linked list of uses of dead REGs in debug insns. */
3418 struct dead_debug_use
3421 struct dead_debug_use
*next
;
3424 /* Linked list of the above, with a bitmap of the REGs in the
3428 struct dead_debug_use
*head
;
3433 /* Initialize DEBUG to an empty list, and clear USED, if given. */
3435 dead_debug_init (struct dead_debug
*debug
, bitmap used
)
3439 debug
->to_rescan
= NULL
;
3441 bitmap_clear (used
);
3444 /* Reset all debug insns with pending uses. Release the bitmap in it,
3445 unless it is USED. USED must be the same bitmap passed to
3448 dead_debug_finish (struct dead_debug
*debug
, bitmap used
)
3450 struct dead_debug_use
*head
;
3453 if (debug
->used
!= used
)
3454 BITMAP_FREE (debug
->used
);
3456 while ((head
= debug
->head
))
3458 insn
= DF_REF_INSN (head
->use
);
3459 if (!head
->next
|| DF_REF_INSN (head
->next
->use
) != insn
)
3461 INSN_VAR_LOCATION_LOC (insn
) = gen_rtx_UNKNOWN_VAR_LOC ();
3462 df_insn_rescan_debug_internal (insn
);
3463 if (debug
->to_rescan
)
3464 bitmap_clear_bit (debug
->to_rescan
, INSN_UID (insn
));
3466 debug
->head
= head
->next
;
3470 if (debug
->to_rescan
)
3475 EXECUTE_IF_SET_IN_BITMAP (debug
->to_rescan
, 0, uid
, bi
)
3477 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
3479 df_insn_rescan (insn_info
->insn
);
3481 BITMAP_FREE (debug
->to_rescan
);
3485 /* Add USE to DEBUG. It must be a dead reference to UREGNO in a debug
3486 insn. Create a bitmap for DEBUG as needed. */
3488 dead_debug_add (struct dead_debug
*debug
, df_ref use
, unsigned int uregno
)
3490 struct dead_debug_use
*newddu
= XNEW (struct dead_debug_use
);
3493 newddu
->next
= debug
->head
;
3494 debug
->head
= newddu
;
3497 debug
->used
= BITMAP_ALLOC (NULL
);
3499 bitmap_set_bit (debug
->used
, uregno
);
3502 /* If UREGNO is referenced by any entry in DEBUG, emit a debug insn
3503 before INSN that binds the REG to a debug temp, and replace all
3504 uses of UREGNO in DEBUG with uses of the debug temp. INSN must be
3505 the insn where UREGNO dies. */
3507 dead_debug_insert_before (struct dead_debug
*debug
, unsigned int uregno
,
3510 struct dead_debug_use
**tailp
= &debug
->head
;
3511 struct dead_debug_use
*cur
;
3512 struct dead_debug_use
*uses
= NULL
;
3513 struct dead_debug_use
**usesp
= &uses
;
3518 if (!debug
->used
|| !bitmap_clear_bit (debug
->used
, uregno
))
3521 /* Move all uses of uregno from debug->head to uses, setting mode to
3522 the widest referenced mode. */
3523 while ((cur
= *tailp
))
3525 if (DF_REF_REGNO (cur
->use
) == uregno
)
3532 || (GET_MODE_BITSIZE (GET_MODE (reg
))
3533 < GET_MODE_BITSIZE (GET_MODE (*DF_REF_REAL_LOC (cur
->use
)))))
3534 reg
= *DF_REF_REAL_LOC (cur
->use
);
3537 tailp
= &(*tailp
)->next
;
3542 /* Create DEBUG_EXPR (and DEBUG_EXPR_DECL). */
3543 dval
= make_debug_expr_from_rtl (reg
);
3545 /* Emit a debug bind insn before the insn in which reg dies. */
3546 bind
= gen_rtx_VAR_LOCATION (GET_MODE (reg
),
3547 DEBUG_EXPR_TREE_DECL (dval
), reg
,
3548 VAR_INIT_STATUS_INITIALIZED
);
3550 bind
= emit_debug_insn_before (bind
, insn
);
3551 df_insn_rescan (bind
);
3553 /* Adjust all uses. */
3554 while ((cur
= uses
))
3556 if (GET_MODE (*DF_REF_REAL_LOC (cur
->use
)) == GET_MODE (reg
))
3557 *DF_REF_REAL_LOC (cur
->use
) = dval
;
3559 *DF_REF_REAL_LOC (cur
->use
)
3560 = gen_lowpart_SUBREG (GET_MODE (*DF_REF_REAL_LOC (cur
->use
)), dval
);
3561 /* ??? Should we simplify subreg of subreg? */
3562 if (debug
->to_rescan
== NULL
)
3563 debug
->to_rescan
= BITMAP_ALLOC (NULL
);
3564 bitmap_set_bit (debug
->to_rescan
, INSN_UID (DF_REF_INSN (cur
->use
)));
3570 /* Recompute the REG_DEAD and REG_UNUSED notes and compute register
3571 info: lifetime, bb, and number of defs and uses for basic block
3572 BB. The three bitvectors are scratch regs used here. */
3575 df_note_bb_compute (unsigned int bb_index
,
3576 bitmap live
, bitmap do_not_gen
, bitmap artificial_uses
)
3578 basic_block bb
= BASIC_BLOCK (bb_index
);
3582 struct dead_debug debug
;
3584 dead_debug_init (&debug
, NULL
);
3586 bitmap_copy (live
, df_get_live_out (bb
));
3587 bitmap_clear (artificial_uses
);
3589 #ifdef REG_DEAD_DEBUGGING
3592 fprintf (dump_file
, "live at bottom ");
3593 df_print_regset (dump_file
, live
);
3597 /* Process the artificial defs and uses at the bottom of the block
3598 to begin processing. */
3599 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
3601 df_ref def
= *def_rec
;
3602 #ifdef REG_DEAD_DEBUGGING
3604 fprintf (dump_file
, "artificial def %d\n", DF_REF_REGNO (def
));
3607 if ((DF_REF_FLAGS (def
) & DF_REF_AT_TOP
) == 0)
3608 bitmap_clear_bit (live
, DF_REF_REGNO (def
));
3611 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
3613 df_ref use
= *use_rec
;
3614 if ((DF_REF_FLAGS (use
) & DF_REF_AT_TOP
) == 0)
3616 unsigned int regno
= DF_REF_REGNO (use
);
3617 bitmap_set_bit (live
, regno
);
3619 /* Notes are not generated for any of the artificial registers
3620 at the bottom of the block. */
3621 bitmap_set_bit (artificial_uses
, regno
);
3625 #ifdef REG_DEAD_DEBUGGING
3628 fprintf (dump_file
, "live before artificials out ");
3629 df_print_regset (dump_file
, live
);
3633 FOR_BB_INSNS_REVERSE (bb
, insn
)
3635 unsigned int uid
= INSN_UID (insn
);
3636 struct df_mw_hardreg
**mws_rec
;
3638 rtx old_unused_notes
;
3644 debug_insn
= DEBUG_INSN_P (insn
);
3646 bitmap_clear (do_not_gen
);
3647 df_kill_notes (insn
, &old_dead_notes
, &old_unused_notes
);
3649 /* Process the defs. */
3652 #ifdef REG_DEAD_DEBUGGING
3655 fprintf (dump_file
, "processing call %d\n live =", INSN_UID (insn
));
3656 df_print_regset (dump_file
, live
);
3659 /* We only care about real sets for calls. Clobbers cannot
3660 be depended on to really die. */
3661 mws_rec
= DF_INSN_UID_MWS (uid
);
3664 struct df_mw_hardreg
*mws
= *mws_rec
;
3665 if ((DF_MWS_REG_DEF_P (mws
))
3666 && !df_ignore_stack_reg (mws
->start_regno
))
3668 = df_set_unused_notes_for_mw (insn
, old_unused_notes
,
3669 mws
, live
, do_not_gen
,
3674 /* All of the defs except the return value are some sort of
3675 clobber. This code is for the return. */
3676 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
3678 df_ref def
= *def_rec
;
3679 unsigned int dregno
= DF_REF_REGNO (def
);
3680 if (!DF_REF_FLAGS_IS_SET (def
, DF_REF_MUST_CLOBBER
| DF_REF_MAY_CLOBBER
))
3683 = df_create_unused_note (insn
, old_unused_notes
,
3684 def
, live
, artificial_uses
);
3685 bitmap_set_bit (do_not_gen
, dregno
);
3688 if (!DF_REF_FLAGS_IS_SET (def
, DF_REF_PARTIAL
| DF_REF_CONDITIONAL
))
3689 bitmap_clear_bit (live
, dregno
);
3695 mws_rec
= DF_INSN_UID_MWS (uid
);
3698 struct df_mw_hardreg
*mws
= *mws_rec
;
3699 if (DF_MWS_REG_DEF_P (mws
))
3701 = df_set_unused_notes_for_mw (insn
, old_unused_notes
,
3702 mws
, live
, do_not_gen
,
3707 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
3709 df_ref def
= *def_rec
;
3710 unsigned int dregno
= DF_REF_REGNO (def
);
3712 = df_create_unused_note (insn
, old_unused_notes
,
3713 def
, live
, artificial_uses
);
3715 if (!DF_REF_FLAGS_IS_SET (def
, DF_REF_MUST_CLOBBER
| DF_REF_MAY_CLOBBER
))
3716 bitmap_set_bit (do_not_gen
, dregno
);
3718 if (!DF_REF_FLAGS_IS_SET (def
, DF_REF_PARTIAL
| DF_REF_CONDITIONAL
))
3719 bitmap_clear_bit (live
, dregno
);
3723 /* Process the uses. */
3724 mws_rec
= DF_INSN_UID_MWS (uid
);
3727 struct df_mw_hardreg
*mws
= *mws_rec
;
3728 if ((DF_MWS_REG_DEF_P (mws
))
3729 && !df_ignore_stack_reg (mws
->start_regno
))
3731 bool really_add_notes
= debug_insn
!= 0;
3734 = df_set_dead_notes_for_mw (insn
, old_dead_notes
,
3735 mws
, live
, do_not_gen
,
3739 if (really_add_notes
)
3745 for (use_rec
= DF_INSN_UID_USES (uid
); *use_rec
; use_rec
++)
3747 df_ref use
= *use_rec
;
3748 unsigned int uregno
= DF_REF_REGNO (use
);
3750 #ifdef REG_DEAD_DEBUGGING
3751 if (dump_file
&& !debug_insn
)
3753 fprintf (dump_file
, " regular looking at use ");
3754 df_ref_debug (use
, dump_file
);
3757 if (!bitmap_bit_p (live
, uregno
))
3763 dead_debug_add (&debug
, use
, uregno
);
3769 dead_debug_insert_before (&debug
, uregno
, insn
);
3771 if ( (!(DF_REF_FLAGS (use
)
3772 & (DF_REF_MW_HARDREG
| DF_REF_READ_WRITE
)))
3773 && (!bitmap_bit_p (do_not_gen
, uregno
))
3774 && (!bitmap_bit_p (artificial_uses
, uregno
))
3775 && (!df_ignore_stack_reg (uregno
)))
3777 rtx reg
= (DF_REF_LOC (use
))
3778 ? *DF_REF_REAL_LOC (use
) : DF_REF_REG (use
);
3779 old_dead_notes
= df_set_note (REG_DEAD
, insn
, old_dead_notes
, reg
);
3781 #ifdef REG_DEAD_DEBUGGING
3782 df_print_note ("adding 4: ", insn
, REG_NOTES (insn
));
3785 /* This register is now live. */
3786 bitmap_set_bit (live
, uregno
);
3790 while (old_unused_notes
)
3792 rtx next
= XEXP (old_unused_notes
, 1);
3793 free_EXPR_LIST_node (old_unused_notes
);
3794 old_unused_notes
= next
;
3796 while (old_dead_notes
)
3798 rtx next
= XEXP (old_dead_notes
, 1);
3799 free_EXPR_LIST_node (old_dead_notes
);
3800 old_dead_notes
= next
;
3803 if (debug_insn
== -1)
3805 /* ??? We could probably do better here, replacing dead
3806 registers with their definitions. */
3807 INSN_VAR_LOCATION_LOC (insn
) = gen_rtx_UNKNOWN_VAR_LOC ();
3808 df_insn_rescan_debug_internal (insn
);
3812 dead_debug_finish (&debug
, NULL
);
3816 /* Compute register info: lifetime, bb, and number of defs and uses. */
3818 df_note_compute (bitmap all_blocks
)
3820 unsigned int bb_index
;
3822 bitmap_head live
, do_not_gen
, artificial_uses
;
3824 bitmap_initialize (&live
, &df_bitmap_obstack
);
3825 bitmap_initialize (&do_not_gen
, &df_bitmap_obstack
);
3826 bitmap_initialize (&artificial_uses
, &df_bitmap_obstack
);
3828 #ifdef REG_DEAD_DEBUGGING
3830 print_rtl_with_bb (dump_file
, get_insns());
3833 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
3835 df_note_bb_compute (bb_index
, &live
, &do_not_gen
, &artificial_uses
);
3838 bitmap_clear (&live
);
3839 bitmap_clear (&do_not_gen
);
3840 bitmap_clear (&artificial_uses
);
3844 /* Free all storage associated with the problem. */
3853 /* All of the information associated every instance of the problem. */
3855 static struct df_problem problem_NOTE
=
3857 DF_NOTE
, /* Problem id. */
3858 DF_NONE
, /* Direction. */
3859 df_note_alloc
, /* Allocate the problem specific data. */
3860 NULL
, /* Reset global information. */
3861 NULL
, /* Free basic block info. */
3862 df_note_compute
, /* Local compute function. */
3863 NULL
, /* Init the solution specific data. */
3864 NULL
, /* Iterative solver. */
3865 NULL
, /* Confluence operator 0. */
3866 NULL
, /* Confluence operator n. */
3867 NULL
, /* Transfer function. */
3868 NULL
, /* Finalize function. */
3869 df_note_free
, /* Free all of the problem information. */
3870 df_note_free
, /* Remove this problem from the stack of dataflow problems. */
3871 NULL
, /* Debugging. */
3872 NULL
, /* Debugging start block. */
3873 NULL
, /* Debugging end block. */
3874 NULL
, /* Incremental solution verify start. */
3875 NULL
, /* Incremental solution verify end. */
3876 &problem_LR
, /* Dependent problem. */
3877 TV_DF_NOTE
, /* Timing variable. */
3878 false /* Reset blocks on dropping out of blocks_to_analyze. */
3882 /* Create a new DATAFLOW instance and add it to an existing instance
3883 of DF. The returned structure is what is used to get at the
3887 df_note_add_problem (void)
3889 df_add_problem (&problem_NOTE
);
3895 /*----------------------------------------------------------------------------
3896 Functions for simulating the effects of single insns.
3898 You can either simulate in the forwards direction, starting from
3899 the top of a block or the backwards direction from the end of the
3900 block. If you go backwards, defs are examined first to clear bits,
3901 then uses are examined to set bits. If you go forwards, defs are
3902 examined first to set bits, then REG_DEAD and REG_UNUSED notes
3903 are examined to clear bits. In either case, the result of examining
3904 a def can be undone (respectively by a use or a REG_UNUSED note).
3906 If you start at the top of the block, use one of DF_LIVE_IN or
3907 DF_LR_IN. If you start at the bottom of the block use one of
3908 DF_LIVE_OUT or DF_LR_OUT. BE SURE TO PASS A COPY OF THESE SETS,
3909 THEY WILL BE DESTROYED.
3910 ----------------------------------------------------------------------------*/
3913 /* Find the set of DEFs for INSN. */
3916 df_simulate_find_defs (rtx insn
, bitmap defs
)
3919 unsigned int uid
= INSN_UID (insn
);
3921 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
3923 df_ref def
= *def_rec
;
3924 bitmap_set_bit (defs
, DF_REF_REGNO (def
));
3928 /* Find the set of real DEFs, which are not clobbers, for INSN. */
3931 df_simulate_find_noclobber_defs (rtx insn
, bitmap defs
)
3934 unsigned int uid
= INSN_UID (insn
);
3936 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
3938 df_ref def
= *def_rec
;
3939 if (!(DF_REF_FLAGS (def
) & (DF_REF_MUST_CLOBBER
| DF_REF_MAY_CLOBBER
)))
3940 bitmap_set_bit (defs
, DF_REF_REGNO (def
));
3945 /* Simulate the effects of the defs of INSN on LIVE. */
3948 df_simulate_defs (rtx insn
, bitmap live
)
3951 unsigned int uid
= INSN_UID (insn
);
3953 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
3955 df_ref def
= *def_rec
;
3956 unsigned int dregno
= DF_REF_REGNO (def
);
3958 /* If the def is to only part of the reg, it does
3959 not kill the other defs that reach here. */
3960 if (!(DF_REF_FLAGS (def
) & (DF_REF_PARTIAL
| DF_REF_CONDITIONAL
)))
3961 bitmap_clear_bit (live
, dregno
);
3966 /* Simulate the effects of the uses of INSN on LIVE. */
3969 df_simulate_uses (rtx insn
, bitmap live
)
3972 unsigned int uid
= INSN_UID (insn
);
3974 if (DEBUG_INSN_P (insn
))
3977 for (use_rec
= DF_INSN_UID_USES (uid
); *use_rec
; use_rec
++)
3979 df_ref use
= *use_rec
;
3980 /* Add use to set of uses in this BB. */
3981 bitmap_set_bit (live
, DF_REF_REGNO (use
));
3986 /* Add back the always live regs in BB to LIVE. */
3989 df_simulate_fixup_sets (basic_block bb
, bitmap live
)
3991 /* These regs are considered always live so if they end up dying
3992 because of some def, we need to bring the back again. */
3993 if (bb_has_eh_pred (bb
))
3994 bitmap_ior_into (live
, &df
->eh_block_artificial_uses
);
3996 bitmap_ior_into (live
, &df
->regular_block_artificial_uses
);
4000 /*----------------------------------------------------------------------------
4001 The following three functions are used only for BACKWARDS scanning:
4002 i.e. they process the defs before the uses.
4004 df_simulate_initialize_backwards should be called first with a
4005 bitvector copyied from the DF_LIVE_OUT or DF_LR_OUT. Then
4006 df_simulate_one_insn_backwards should be called for each insn in
4007 the block, starting with the last one. Finally,
4008 df_simulate_finalize_backwards can be called to get a new value
4009 of the sets at the top of the block (this is rarely used).
4010 ----------------------------------------------------------------------------*/
4012 /* Apply the artificial uses and defs at the end of BB in a backwards
4016 df_simulate_initialize_backwards (basic_block bb
, bitmap live
)
4020 int bb_index
= bb
->index
;
4022 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
4024 df_ref def
= *def_rec
;
4025 if ((DF_REF_FLAGS (def
) & DF_REF_AT_TOP
) == 0)
4026 bitmap_clear_bit (live
, DF_REF_REGNO (def
));
4029 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
4031 df_ref use
= *use_rec
;
4032 if ((DF_REF_FLAGS (use
) & DF_REF_AT_TOP
) == 0)
4033 bitmap_set_bit (live
, DF_REF_REGNO (use
));
4038 /* Simulate the backwards effects of INSN on the bitmap LIVE. */
4041 df_simulate_one_insn_backwards (basic_block bb
, rtx insn
, bitmap live
)
4043 if (!NONDEBUG_INSN_P (insn
))
4046 df_simulate_defs (insn
, live
);
4047 df_simulate_uses (insn
, live
);
4048 df_simulate_fixup_sets (bb
, live
);
4052 /* Apply the artificial uses and defs at the top of BB in a backwards
4056 df_simulate_finalize_backwards (basic_block bb
, bitmap live
)
4062 int bb_index
= bb
->index
;
4064 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
4066 df_ref def
= *def_rec
;
4067 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
4068 bitmap_clear_bit (live
, DF_REF_REGNO (def
));
4072 for (use_rec
= df_get_artificial_uses (bb_index
); *use_rec
; use_rec
++)
4074 df_ref use
= *use_rec
;
4075 if (DF_REF_FLAGS (use
) & DF_REF_AT_TOP
)
4076 bitmap_set_bit (live
, DF_REF_REGNO (use
));
4080 /*----------------------------------------------------------------------------
4081 The following three functions are used only for FORWARDS scanning:
4082 i.e. they process the defs and the REG_DEAD and REG_UNUSED notes.
4083 Thus it is important to add the DF_NOTES problem to the stack of
4084 problems computed before using these functions.
4086 df_simulate_initialize_forwards should be called first with a
4087 bitvector copyied from the DF_LIVE_IN or DF_LR_IN. Then
4088 df_simulate_one_insn_forwards should be called for each insn in
4089 the block, starting with the first one.
4090 ----------------------------------------------------------------------------*/
4092 /* Initialize the LIVE bitmap, which should be copied from DF_LIVE_IN or
4093 DF_LR_IN for basic block BB, for forward scanning by marking artificial
4097 df_simulate_initialize_forwards (basic_block bb
, bitmap live
)
4100 int bb_index
= bb
->index
;
4102 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
4104 df_ref def
= *def_rec
;
4105 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
4106 bitmap_set_bit (live
, DF_REF_REGNO (def
));
4110 /* Simulate the forwards effects of INSN on the bitmap LIVE. */
4113 df_simulate_one_insn_forwards (basic_block bb
, rtx insn
, bitmap live
)
4116 if (! INSN_P (insn
))
4119 /* Make sure that DF_NOTE really is an active df problem. */
4120 gcc_assert (df_note
);
4122 /* Note that this is the opposite as how the problem is defined, because
4123 in the LR problem defs _kill_ liveness. However, they do so backwards,
4124 while here the scan is performed forwards! So, first assume that the
4125 def is live, and if this is not true REG_UNUSED notes will rectify the
4127 df_simulate_find_noclobber_defs (insn
, live
);
4129 /* Clear all of the registers that go dead. */
4130 for (link
= REG_NOTES (insn
); link
; link
= XEXP (link
, 1))
4132 switch (REG_NOTE_KIND (link
))
4137 rtx reg
= XEXP (link
, 0);
4138 int regno
= REGNO (reg
);
4139 if (regno
< FIRST_PSEUDO_REGISTER
)
4141 int n
= hard_regno_nregs
[regno
][GET_MODE (reg
)];
4143 bitmap_clear_bit (live
, regno
+ n
);
4146 bitmap_clear_bit (live
, regno
);
4153 df_simulate_fixup_sets (bb
, live
);
4158 /*----------------------------------------------------------------------------
4159 MULTIPLE DEFINITIONS
4161 Find the locations in the function reached by multiple definition sites
4162 for a live pseudo. In and out bitvectors are built for each basic
4163 block. They are restricted for efficiency to live registers.
4165 The gen and kill sets for the problem are obvious. Together they
4166 include all defined registers in a basic block; the gen set includes
4167 registers where a partial or conditional or may-clobber definition is
4168 last in the BB, while the kill set includes registers with a complete
4169 definition coming last. However, the computation of the dataflow
4170 itself is interesting.
4172 The idea behind it comes from SSA form's iterated dominance frontier
4173 criterion for inserting PHI functions. Just like in that case, we can use
4174 the dominance frontier to find places where multiple definitions meet;
4175 a register X defined in a basic block BB1 has multiple definitions in
4176 basic blocks in BB1's dominance frontier.
4178 So, the in-set of a basic block BB2 is not just the union of the
4179 out-sets of BB2's predecessors, but includes some more bits that come
4180 from the basic blocks of whose dominance frontier BB2 is part (BB1 in
4181 the previous paragraph). I called this set the init-set of BB2.
4183 (Note: I actually use the kill-set only to build the init-set.
4184 gen bits are anyway propagated from BB1 to BB2 by dataflow).
4186 For example, if you have
4190 if <...> goto BB2 else goto BB3;
4198 you have BB3 in BB2's dominance frontier but not in BB1's, so that the
4199 init-set of BB3 includes r10 and r12, but not r11. Note that we do
4200 not need to iterate the dominance frontier, because we do not insert
4201 anything like PHI functions there! Instead, dataflow will take care of
4202 propagating the information to BB3's successors.
4203 ---------------------------------------------------------------------------*/
4205 /* Private data used to verify the solution for this problem. */
4206 struct df_md_problem_data
4208 /* An obstack for the bitmaps we need for this problem. */
4209 bitmap_obstack md_bitmaps
;
4212 /* Scratch var used by transfer functions. This is used to do md analysis
4213 only for live registers. */
4214 static bitmap_head df_md_scratch
;
4216 /* Set basic block info. */
4219 df_md_set_bb_info (unsigned int index
,
4220 struct df_md_bb_info
*bb_info
)
4223 gcc_assert (index
< df_md
->block_info_size
);
4224 df_md
->block_info
[index
] = bb_info
;
4229 df_md_free_bb_info (basic_block bb ATTRIBUTE_UNUSED
,
4232 struct df_md_bb_info
*bb_info
= (struct df_md_bb_info
*) vbb_info
;
4235 bitmap_clear (&bb_info
->kill
);
4236 bitmap_clear (&bb_info
->gen
);
4237 bitmap_clear (&bb_info
->init
);
4238 bitmap_clear (&bb_info
->in
);
4239 bitmap_clear (&bb_info
->out
);
4240 pool_free (df_md
->block_pool
, bb_info
);
4245 /* Allocate or reset bitmaps for DF_MD. The solution bits are
4246 not touched unless the block is new. */
4249 df_md_alloc (bitmap all_blocks
)
4251 unsigned int bb_index
;
4253 struct df_md_problem_data
*problem_data
;
4255 if (!df_md
->block_pool
)
4256 df_md
->block_pool
= create_alloc_pool ("df_md_block pool",
4257 sizeof (struct df_md_bb_info
), 50);
4259 df_grow_bb_info (df_md
);
4260 if (df_md
->problem_data
)
4261 problem_data
= (struct df_md_problem_data
*) df_md
->problem_data
;
4264 problem_data
= XNEW (struct df_md_problem_data
);
4265 df_md
->problem_data
= problem_data
;
4266 bitmap_obstack_initialize (&problem_data
->md_bitmaps
);
4268 bitmap_initialize (&df_md_scratch
, &problem_data
->md_bitmaps
);
4270 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
4272 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb_index
);
4275 bitmap_clear (&bb_info
->init
);
4276 bitmap_clear (&bb_info
->gen
);
4277 bitmap_clear (&bb_info
->kill
);
4278 bitmap_clear (&bb_info
->in
);
4279 bitmap_clear (&bb_info
->out
);
4283 bb_info
= (struct df_md_bb_info
*) pool_alloc (df_md
->block_pool
);
4284 df_md_set_bb_info (bb_index
, bb_info
);
4285 bitmap_initialize (&bb_info
->init
, &problem_data
->md_bitmaps
);
4286 bitmap_initialize (&bb_info
->gen
, &problem_data
->md_bitmaps
);
4287 bitmap_initialize (&bb_info
->kill
, &problem_data
->md_bitmaps
);
4288 bitmap_initialize (&bb_info
->in
, &problem_data
->md_bitmaps
);
4289 bitmap_initialize (&bb_info
->out
, &problem_data
->md_bitmaps
);
4293 df_md
->optional_p
= true;
4296 /* Add the effect of the top artificial defs of BB to the multiple definitions
4300 df_md_simulate_artificial_defs_at_top (basic_block bb
, bitmap local_md
)
4302 int bb_index
= bb
->index
;
4304 for (def_rec
= df_get_artificial_defs (bb_index
); *def_rec
; def_rec
++)
4306 df_ref def
= *def_rec
;
4307 if (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
)
4309 unsigned int dregno
= DF_REF_REGNO (def
);
4310 if (DF_REF_FLAGS (def
)
4311 & (DF_REF_PARTIAL
| DF_REF_CONDITIONAL
| DF_REF_MAY_CLOBBER
))
4312 bitmap_set_bit (local_md
, dregno
);
4314 bitmap_clear_bit (local_md
, dregno
);
4320 /* Add the effect of the defs of INSN to the reaching definitions bitmap
4324 df_md_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED
, rtx insn
,
4327 unsigned uid
= INSN_UID (insn
);
4330 for (def_rec
= DF_INSN_UID_DEFS (uid
); *def_rec
; def_rec
++)
4332 df_ref def
= *def_rec
;
4333 unsigned int dregno
= DF_REF_REGNO (def
);
4334 if ((!(df
->changeable_flags
& DF_NO_HARD_REGS
))
4335 || (dregno
>= FIRST_PSEUDO_REGISTER
))
4337 if (DF_REF_FLAGS (def
)
4338 & (DF_REF_PARTIAL
| DF_REF_CONDITIONAL
| DF_REF_MAY_CLOBBER
))
4339 bitmap_set_bit (local_md
, DF_REF_ID (def
));
4341 bitmap_clear_bit (local_md
, DF_REF_ID (def
));
4347 df_md_bb_local_compute_process_def (struct df_md_bb_info
*bb_info
,
4352 bitmap_clear (&seen_in_insn
);
4354 while ((def
= *def_rec
++) != NULL
)
4356 unsigned int dregno
= DF_REF_REGNO (def
);
4357 if (((!(df
->changeable_flags
& DF_NO_HARD_REGS
))
4358 || (dregno
>= FIRST_PSEUDO_REGISTER
))
4359 && top_flag
== (DF_REF_FLAGS (def
) & DF_REF_AT_TOP
))
4361 if (!bitmap_bit_p (&seen_in_insn
, dregno
))
4363 if (DF_REF_FLAGS (def
)
4364 & (DF_REF_PARTIAL
| DF_REF_CONDITIONAL
| DF_REF_MAY_CLOBBER
))
4366 bitmap_set_bit (&bb_info
->gen
, dregno
);
4367 bitmap_clear_bit (&bb_info
->kill
, dregno
);
4371 /* When we find a clobber and a regular def,
4372 make sure the regular def wins. */
4373 bitmap_set_bit (&seen_in_insn
, dregno
);
4374 bitmap_set_bit (&bb_info
->kill
, dregno
);
4375 bitmap_clear_bit (&bb_info
->gen
, dregno
);
4383 /* Compute local multiple def info for basic block BB. */
4386 df_md_bb_local_compute (unsigned int bb_index
)
4388 basic_block bb
= BASIC_BLOCK (bb_index
);
4389 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb_index
);
4392 /* Artificials are only hard regs. */
4393 if (!(df
->changeable_flags
& DF_NO_HARD_REGS
))
4394 df_md_bb_local_compute_process_def (bb_info
,
4395 df_get_artificial_defs (bb_index
),
4398 FOR_BB_INSNS (bb
, insn
)
4400 unsigned int uid
= INSN_UID (insn
);
4404 df_md_bb_local_compute_process_def (bb_info
, DF_INSN_UID_DEFS (uid
), 0);
4407 if (!(df
->changeable_flags
& DF_NO_HARD_REGS
))
4408 df_md_bb_local_compute_process_def (bb_info
,
4409 df_get_artificial_defs (bb_index
),
4413 /* Compute local reaching def info for each basic block within BLOCKS. */
4416 df_md_local_compute (bitmap all_blocks
)
4418 unsigned int bb_index
, df_bb_index
;
4419 bitmap_iterator bi1
, bi2
;
4421 bitmap_head
*frontiers
;
4423 bitmap_initialize (&seen_in_insn
, &bitmap_default_obstack
);
4425 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi1
)
4427 df_md_bb_local_compute (bb_index
);
4430 bitmap_clear (&seen_in_insn
);
4432 frontiers
= XNEWVEC (bitmap_head
, last_basic_block
);
4434 bitmap_initialize (&frontiers
[bb
->index
], &bitmap_default_obstack
);
4436 compute_dominance_frontiers (frontiers
);
4438 /* Add each basic block's kills to the nodes in the frontier of the BB. */
4439 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi1
)
4441 bitmap kill
= &df_md_get_bb_info (bb_index
)->kill
;
4442 EXECUTE_IF_SET_IN_BITMAP (&frontiers
[bb_index
], 0, df_bb_index
, bi2
)
4444 basic_block bb
= BASIC_BLOCK (df_bb_index
);
4445 if (bitmap_bit_p (all_blocks
, df_bb_index
))
4446 bitmap_ior_and_into (&df_md_get_bb_info (df_bb_index
)->init
, kill
,
4447 df_get_live_in (bb
));
4452 bitmap_clear (&frontiers
[bb
->index
]);
4457 /* Reset the global solution for recalculation. */
4460 df_md_reset (bitmap all_blocks
)
4462 unsigned int bb_index
;
4465 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
4467 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb_index
);
4468 gcc_assert (bb_info
);
4469 bitmap_clear (&bb_info
->in
);
4470 bitmap_clear (&bb_info
->out
);
4475 df_md_transfer_function (int bb_index
)
4477 basic_block bb
= BASIC_BLOCK (bb_index
);
4478 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb_index
);
4479 bitmap in
= &bb_info
->in
;
4480 bitmap out
= &bb_info
->out
;
4481 bitmap gen
= &bb_info
->gen
;
4482 bitmap kill
= &bb_info
->kill
;
4484 /* We need to use a scratch set here so that the value returned from this
4485 function invocation properly reflects whether the sets changed in a
4486 significant way; i.e. not just because the live set was anded in. */
4487 bitmap_and (&df_md_scratch
, gen
, df_get_live_out (bb
));
4489 /* Multiple definitions of a register are not relevant if it is not
4490 live. Thus we trim the result to the places where it is live. */
4491 bitmap_and_into (in
, df_get_live_in (bb
));
4493 return bitmap_ior_and_compl (out
, &df_md_scratch
, in
, kill
);
4496 /* Initialize the solution bit vectors for problem. */
4499 df_md_init (bitmap all_blocks
)
4501 unsigned int bb_index
;
4504 EXECUTE_IF_SET_IN_BITMAP (all_blocks
, 0, bb_index
, bi
)
4506 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb_index
);
4508 bitmap_copy (&bb_info
->in
, &bb_info
->init
);
4509 df_md_transfer_function (bb_index
);
4514 df_md_confluence_0 (basic_block bb
)
4516 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb
->index
);
4517 bitmap_copy (&bb_info
->in
, &bb_info
->init
);
4520 /* In of target gets or of out of source. */
4523 df_md_confluence_n (edge e
)
4525 bitmap op1
= &df_md_get_bb_info (e
->dest
->index
)->in
;
4526 bitmap op2
= &df_md_get_bb_info (e
->src
->index
)->out
;
4528 if (e
->flags
& EDGE_FAKE
)
4531 if (e
->flags
& EDGE_EH
)
4532 bitmap_ior_and_compl_into (op1
, op2
, regs_invalidated_by_call_regset
);
4534 bitmap_ior_into (op1
, op2
);
4537 /* Free all storage associated with the problem. */
4542 struct df_md_problem_data
*problem_data
4543 = (struct df_md_problem_data
*) df_md
->problem_data
;
4545 bitmap_obstack_release (&problem_data
->md_bitmaps
);
4546 free_alloc_pool (df_md
->block_pool
);
4547 free (problem_data
);
4548 df_md
->problem_data
= NULL
;
4550 df_md
->block_info_size
= 0;
4551 free (df_md
->block_info
);
4556 /* Debugging info at top of bb. */
4559 df_md_top_dump (basic_block bb
, FILE *file
)
4561 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb
->index
);
4565 fprintf (file
, ";; md in \t");
4566 df_print_regset (file
, &bb_info
->in
);
4567 fprintf (file
, ";; md init \t");
4568 df_print_regset (file
, &bb_info
->init
);
4569 fprintf (file
, ";; md gen \t");
4570 df_print_regset (file
, &bb_info
->gen
);
4571 fprintf (file
, ";; md kill \t");
4572 df_print_regset (file
, &bb_info
->kill
);
4575 /* Debugging info at bottom of bb. */
4578 df_md_bottom_dump (basic_block bb
, FILE *file
)
4580 struct df_md_bb_info
*bb_info
= df_md_get_bb_info (bb
->index
);
4584 fprintf (file
, ";; md out \t");
4585 df_print_regset (file
, &bb_info
->out
);
4588 static struct df_problem problem_MD
=
4590 DF_MD
, /* Problem id. */
4591 DF_FORWARD
, /* Direction. */
4592 df_md_alloc
, /* Allocate the problem specific data. */
4593 df_md_reset
, /* Reset global information. */
4594 df_md_free_bb_info
, /* Free basic block info. */
4595 df_md_local_compute
, /* Local compute function. */
4596 df_md_init
, /* Init the solution specific data. */
4597 df_worklist_dataflow
, /* Worklist solver. */
4598 df_md_confluence_0
, /* Confluence operator 0. */
4599 df_md_confluence_n
, /* Confluence operator n. */
4600 df_md_transfer_function
, /* Transfer function. */
4601 NULL
, /* Finalize function. */
4602 df_md_free
, /* Free all of the problem information. */
4603 df_md_free
, /* Remove this problem from the stack of dataflow problems. */
4604 NULL
, /* Debugging. */
4605 df_md_top_dump
, /* Debugging start block. */
4606 df_md_bottom_dump
, /* Debugging end block. */
4607 NULL
, /* Incremental solution verify start. */
4608 NULL
, /* Incremental solution verify end. */
4609 NULL
, /* Dependent problem. */
4610 TV_DF_MD
, /* Timing variable. */
4611 false /* Reset blocks on dropping out of blocks_to_analyze. */
4614 /* Create a new MD instance and add it to the existing instance
4618 df_md_add_problem (void)
4620 df_add_problem (&problem_MD
);