1 /* Scanning of rtl for dataflow analysis.
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"
45 #include "target-def.h"
47 #include "tree-pass.h"
48 #include "emit-rtl.h" /* FIXME: Can go away once crtl is moved to rtl.h. */
51 DEF_VEC_ALLOC_P_STACK(df_ref
);
53 #define VEC_df_ref_stack_alloc(alloc) VEC_stack_alloc (df_ref, alloc)
55 typedef struct df_mw_hardreg
*df_mw_hardreg_ptr
;
57 DEF_VEC_P(df_mw_hardreg_ptr
);
58 DEF_VEC_ALLOC_P_STACK(df_mw_hardreg_ptr
);
60 #define VEC_df_mw_hardreg_ptr_stack_alloc(alloc) \
61 VEC_stack_alloc (df_mw_hardreg_ptr, alloc)
64 #define HAVE_epilogue 0
67 #define HAVE_prologue 0
69 #ifndef HAVE_sibcall_epilogue
70 #define HAVE_sibcall_epilogue 0
74 #define EPILOGUE_USES(REGNO) 0
77 /* The following two macros free the vecs that hold either the refs or
78 the mw refs. They are a little tricky because the vec has 0
79 elements is special and is not to be freed. */
80 #define df_scan_free_ref_vec(V) \
86 #define df_scan_free_mws_vec(V) \
92 /* The set of hard registers in eliminables[i].from. */
94 static HARD_REG_SET elim_reg_set
;
96 /* Initialize ur_in and ur_out as if all hard registers were partially
99 struct df_collection_rec
101 VEC(df_ref
,stack
) *def_vec
;
102 VEC(df_ref
,stack
) *use_vec
;
103 VEC(df_ref
,stack
) *eq_use_vec
;
104 VEC(df_mw_hardreg_ptr
,stack
) *mw_vec
;
107 static df_ref df_null_ref_rec
[1];
108 static struct df_mw_hardreg
* df_null_mw_rec
[1];
110 static void df_ref_record (enum df_ref_class
, struct df_collection_rec
*,
112 basic_block
, struct df_insn_info
*,
113 enum df_ref_type
, int ref_flags
);
114 static void df_def_record_1 (struct df_collection_rec
*, rtx
,
115 basic_block
, struct df_insn_info
*,
117 static void df_defs_record (struct df_collection_rec
*, rtx
,
118 basic_block
, struct df_insn_info
*,
120 static void df_uses_record (struct df_collection_rec
*,
121 rtx
*, enum df_ref_type
,
122 basic_block
, struct df_insn_info
*,
125 static df_ref
df_ref_create_structure (enum df_ref_class
,
126 struct df_collection_rec
*, rtx
, rtx
*,
127 basic_block
, struct df_insn_info
*,
128 enum df_ref_type
, int ref_flags
);
129 static void df_insn_refs_collect (struct df_collection_rec
*,
130 basic_block
, struct df_insn_info
*);
131 static void df_canonize_collection_rec (struct df_collection_rec
*);
133 static void df_get_regular_block_artificial_uses (bitmap
);
134 static void df_get_eh_block_artificial_uses (bitmap
);
136 static void df_record_entry_block_defs (bitmap
);
137 static void df_record_exit_block_uses (bitmap
);
138 static void df_get_exit_block_use_set (bitmap
);
139 static void df_get_entry_block_def_set (bitmap
);
140 static void df_grow_ref_info (struct df_ref_info
*, unsigned int);
141 static void df_ref_chain_delete_du_chain (df_ref
*);
142 static void df_ref_chain_delete (df_ref
*);
144 static void df_refs_add_to_chains (struct df_collection_rec
*,
147 static bool df_insn_refs_verify (struct df_collection_rec
*, basic_block
, rtx
, bool);
148 static void df_entry_block_defs_collect (struct df_collection_rec
*, bitmap
);
149 static void df_exit_block_uses_collect (struct df_collection_rec
*, bitmap
);
150 static void df_install_ref (df_ref
, struct df_reg_info
*,
151 struct df_ref_info
*, bool);
153 static int df_ref_compare (const void *, const void *);
154 static int df_mw_compare (const void *, const void *);
156 /* Indexed by hardware reg number, is true if that register is ever
157 used in the current function.
159 In df-scan.c, this is set up to record the hard regs used
160 explicitly. Reload adds in the hard regs used for holding pseudo
161 regs. Final uses it to generate the code in the function prologue
162 and epilogue to save and restore registers as needed. */
164 static bool regs_ever_live
[FIRST_PSEUDO_REGISTER
];
166 /*----------------------------------------------------------------------------
167 SCANNING DATAFLOW PROBLEM
169 There are several ways in which scanning looks just like the other
170 dataflow problems. It shares the all the mechanisms for local info
171 as well as basic block info. Where it differs is when and how often
172 it gets run. It also has no need for the iterative solver.
173 ----------------------------------------------------------------------------*/
175 /* Problem data for the scanning dataflow function. */
176 struct df_scan_problem_data
178 alloc_pool ref_base_pool
;
179 alloc_pool ref_artificial_pool
;
180 alloc_pool ref_regular_pool
;
181 alloc_pool insn_pool
;
183 alloc_pool mw_reg_pool
;
184 bitmap_obstack reg_bitmaps
;
185 bitmap_obstack insn_bitmaps
;
188 typedef struct df_scan_bb_info
*df_scan_bb_info_t
;
191 /* Internal function to shut down the scanning problem. */
193 df_scan_free_internal (void)
195 struct df_scan_problem_data
*problem_data
196 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
200 /* The vectors that hold the refs are not pool allocated because
201 they come in many sizes. This makes them impossible to delete
203 for (i
= 0; i
< DF_INSN_SIZE(); i
++)
205 struct df_insn_info
*insn_info
= DF_INSN_UID_GET(i
);
206 /* Skip the insns that have no insn_info or have been
210 df_scan_free_ref_vec (insn_info
->defs
);
211 df_scan_free_ref_vec (insn_info
->uses
);
212 df_scan_free_ref_vec (insn_info
->eq_uses
);
213 df_scan_free_mws_vec (insn_info
->mw_hardregs
);
219 unsigned int bb_index
= bb
->index
;
220 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb_index
);
223 df_scan_free_ref_vec (bb_info
->artificial_defs
);
224 df_scan_free_ref_vec (bb_info
->artificial_uses
);
228 free (df
->def_info
.refs
);
229 free (df
->def_info
.begin
);
230 free (df
->def_info
.count
);
231 memset (&df
->def_info
, 0, (sizeof (struct df_ref_info
)));
233 free (df
->use_info
.refs
);
234 free (df
->use_info
.begin
);
235 free (df
->use_info
.count
);
236 memset (&df
->use_info
, 0, (sizeof (struct df_ref_info
)));
242 free (df
->eq_use_regs
);
243 df
->eq_use_regs
= NULL
;
251 free (df_scan
->block_info
);
252 df_scan
->block_info
= NULL
;
253 df_scan
->block_info_size
= 0;
255 bitmap_clear (&df
->hardware_regs_used
);
256 bitmap_clear (&df
->regular_block_artificial_uses
);
257 bitmap_clear (&df
->eh_block_artificial_uses
);
258 BITMAP_FREE (df
->entry_block_defs
);
259 BITMAP_FREE (df
->exit_block_uses
);
260 bitmap_clear (&df
->insns_to_delete
);
261 bitmap_clear (&df
->insns_to_rescan
);
262 bitmap_clear (&df
->insns_to_notes_rescan
);
264 free_alloc_pool (problem_data
->ref_base_pool
);
265 free_alloc_pool (problem_data
->ref_artificial_pool
);
266 free_alloc_pool (problem_data
->ref_regular_pool
);
267 free_alloc_pool (problem_data
->insn_pool
);
268 free_alloc_pool (problem_data
->reg_pool
);
269 free_alloc_pool (problem_data
->mw_reg_pool
);
270 bitmap_obstack_release (&problem_data
->reg_bitmaps
);
271 bitmap_obstack_release (&problem_data
->insn_bitmaps
);
272 free (df_scan
->problem_data
);
276 /* Free basic block info. */
279 df_scan_free_bb_info (basic_block bb
, void *vbb_info
)
281 struct df_scan_bb_info
*bb_info
= (struct df_scan_bb_info
*) vbb_info
;
282 unsigned int bb_index
= bb
->index
;
284 /* See if bb_info is initialized. */
285 if (bb_info
->artificial_defs
)
288 FOR_BB_INSNS (bb
, insn
)
291 /* Record defs within INSN. */
292 df_insn_delete (bb
, INSN_UID (insn
));
295 if (bb_index
< df_scan
->block_info_size
)
296 bb_info
= df_scan_get_bb_info (bb_index
);
298 /* Get rid of any artificial uses or defs. */
299 if (bb_info
->artificial_defs
)
301 df_ref_chain_delete_du_chain (bb_info
->artificial_defs
);
302 df_ref_chain_delete_du_chain (bb_info
->artificial_uses
);
303 df_ref_chain_delete (bb_info
->artificial_defs
);
304 df_ref_chain_delete (bb_info
->artificial_uses
);
305 bb_info
->artificial_defs
= NULL
;
306 bb_info
->artificial_uses
= NULL
;
312 /* Allocate the problem data for the scanning problem. This should be
313 called when the problem is created or when the entire function is to
316 df_scan_alloc (bitmap all_blocks ATTRIBUTE_UNUSED
)
318 struct df_scan_problem_data
*problem_data
;
319 unsigned int insn_num
= get_max_uid () + 1;
320 unsigned int block_size
= 400;
323 /* Given the number of pools, this is really faster than tearing
325 if (df_scan
->problem_data
)
326 df_scan_free_internal ();
328 problem_data
= XNEW (struct df_scan_problem_data
);
329 df_scan
->problem_data
= problem_data
;
330 df_scan
->computed
= true;
332 problem_data
->ref_base_pool
333 = create_alloc_pool ("df_scan ref base",
334 sizeof (struct df_base_ref
), block_size
);
335 problem_data
->ref_artificial_pool
336 = create_alloc_pool ("df_scan ref artificial",
337 sizeof (struct df_artificial_ref
), block_size
);
338 problem_data
->ref_regular_pool
339 = create_alloc_pool ("df_scan ref regular",
340 sizeof (struct df_regular_ref
), block_size
);
341 problem_data
->insn_pool
342 = create_alloc_pool ("df_scan insn",
343 sizeof (struct df_insn_info
), block_size
);
344 problem_data
->reg_pool
345 = create_alloc_pool ("df_scan reg",
346 sizeof (struct df_reg_info
), block_size
);
347 problem_data
->mw_reg_pool
348 = create_alloc_pool ("df_scan mw_reg",
349 sizeof (struct df_mw_hardreg
), block_size
);
351 bitmap_obstack_initialize (&problem_data
->reg_bitmaps
);
352 bitmap_obstack_initialize (&problem_data
->insn_bitmaps
);
354 insn_num
+= insn_num
/ 4;
357 df_grow_insn_info ();
358 df_grow_bb_info (df_scan
);
362 unsigned int bb_index
= bb
->index
;
363 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb_index
);
364 bb_info
->artificial_defs
= NULL
;
365 bb_info
->artificial_uses
= NULL
;
368 bitmap_initialize (&df
->hardware_regs_used
, &problem_data
->reg_bitmaps
);
369 bitmap_initialize (&df
->regular_block_artificial_uses
, &problem_data
->reg_bitmaps
);
370 bitmap_initialize (&df
->eh_block_artificial_uses
, &problem_data
->reg_bitmaps
);
371 df
->entry_block_defs
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
372 df
->exit_block_uses
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
373 bitmap_initialize (&df
->insns_to_delete
, &problem_data
->insn_bitmaps
);
374 bitmap_initialize (&df
->insns_to_rescan
, &problem_data
->insn_bitmaps
);
375 bitmap_initialize (&df
->insns_to_notes_rescan
, &problem_data
->insn_bitmaps
);
376 df_scan
->optional_p
= false;
380 /* Free all of the data associated with the scan problem. */
385 if (df_scan
->problem_data
)
386 df_scan_free_internal ();
388 if (df
->blocks_to_analyze
)
390 BITMAP_FREE (df
->blocks_to_analyze
);
391 df
->blocks_to_analyze
= NULL
;
397 /* Dump the preamble for DF_SCAN dump. */
399 df_scan_start_dump (FILE *file ATTRIBUTE_UNUSED
)
410 fprintf (file
, ";; invalidated by call \t");
411 df_print_regset (file
, regs_invalidated_by_call_regset
);
412 fprintf (file
, ";; hardware regs used \t");
413 df_print_regset (file
, &df
->hardware_regs_used
);
414 fprintf (file
, ";; regular block artificial uses \t");
415 df_print_regset (file
, &df
->regular_block_artificial_uses
);
416 fprintf (file
, ";; eh block artificial uses \t");
417 df_print_regset (file
, &df
->eh_block_artificial_uses
);
418 fprintf (file
, ";; entry block defs \t");
419 df_print_regset (file
, df
->entry_block_defs
);
420 fprintf (file
, ";; exit block uses \t");
421 df_print_regset (file
, df
->exit_block_uses
);
422 fprintf (file
, ";; regs ever live \t");
423 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
424 if (df_regs_ever_live_p (i
))
425 fprintf (file
, " %d[%s]", i
, reg_names
[i
]);
426 fprintf (file
, "\n;; ref usage \t");
428 for (i
= 0; i
< (int)df
->regs_inited
; i
++)
429 if (DF_REG_DEF_COUNT (i
) || DF_REG_USE_COUNT (i
) || DF_REG_EQ_USE_COUNT (i
))
431 const char * sep
= "";
433 fprintf (file
, "r%d={", i
);
434 if (DF_REG_DEF_COUNT (i
))
436 fprintf (file
, "%dd", DF_REG_DEF_COUNT (i
));
438 dcount
+= DF_REG_DEF_COUNT (i
);
440 if (DF_REG_USE_COUNT (i
))
442 fprintf (file
, "%s%du", sep
, DF_REG_USE_COUNT (i
));
444 ucount
+= DF_REG_USE_COUNT (i
);
446 if (DF_REG_EQ_USE_COUNT (i
))
448 fprintf (file
, "%s%dd", sep
, DF_REG_EQ_USE_COUNT (i
));
449 ecount
+= DF_REG_EQ_USE_COUNT (i
);
451 fprintf (file
, "} ");
455 FOR_BB_INSNS (bb
, insn
)
464 fprintf (file
, "\n;; total ref usage %d{%dd,%du,%de} in %d{%d regular + %d call} insns.\n",
465 dcount
+ ucount
+ ecount
, dcount
, ucount
, ecount
, icount
+ ccount
, icount
, ccount
);
468 /* Dump the bb_info for a given basic block. */
470 df_scan_start_block (basic_block bb
, FILE *file
)
472 struct df_scan_bb_info
*bb_info
473 = df_scan_get_bb_info (bb
->index
);
477 fprintf (file
, ";; bb %d artificial_defs: ", bb
->index
);
478 df_refs_chain_dump (bb_info
->artificial_defs
, true, file
);
479 fprintf (file
, "\n;; bb %d artificial_uses: ", bb
->index
);
480 df_refs_chain_dump (bb_info
->artificial_uses
, true, file
);
481 fprintf (file
, "\n");
486 FOR_BB_INSNS (bb
, insn
)
488 df_insn_debug (insn
, false, file
);
493 static struct df_problem problem_SCAN
=
495 DF_SCAN
, /* Problem id. */
496 DF_NONE
, /* Direction. */
497 df_scan_alloc
, /* Allocate the problem specific data. */
498 NULL
, /* Reset global information. */
499 df_scan_free_bb_info
, /* Free basic block info. */
500 NULL
, /* Local compute function. */
501 NULL
, /* Init the solution specific data. */
502 NULL
, /* Iterative solver. */
503 NULL
, /* Confluence operator 0. */
504 NULL
, /* Confluence operator n. */
505 NULL
, /* Transfer function. */
506 NULL
, /* Finalize function. */
507 df_scan_free
, /* Free all of the problem information. */
508 NULL
, /* Remove this problem from the stack of dataflow problems. */
509 df_scan_start_dump
, /* Debugging. */
510 df_scan_start_block
, /* Debugging start block. */
511 NULL
, /* Debugging end block. */
512 NULL
, /* Incremental solution verify start. */
513 NULL
, /* Incremental solution verify end. */
514 NULL
, /* Dependent problem. */
515 sizeof (struct df_scan_bb_info
),/* Size of entry of block_info array. */
516 TV_DF_SCAN
, /* Timing variable. */
517 false /* Reset blocks on dropping out of blocks_to_analyze. */
521 /* Create a new DATAFLOW instance and add it to an existing instance
522 of DF. The returned structure is what is used to get at the
526 df_scan_add_problem (void)
528 df_add_problem (&problem_SCAN
);
532 /*----------------------------------------------------------------------------
533 Storage Allocation Utilities
534 ----------------------------------------------------------------------------*/
537 /* First, grow the reg_info information. If the current size is less than
538 the number of pseudos, grow to 25% more than the number of
541 Second, assure that all of the slots up to max_reg_num have been
542 filled with reg_info structures. */
545 df_grow_reg_info (void)
547 unsigned int max_reg
= max_reg_num ();
548 unsigned int new_size
= max_reg
;
549 struct df_scan_problem_data
*problem_data
550 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
553 if (df
->regs_size
< new_size
)
555 new_size
+= new_size
/ 4;
556 df
->def_regs
= XRESIZEVEC (struct df_reg_info
*, df
->def_regs
, new_size
);
557 df
->use_regs
= XRESIZEVEC (struct df_reg_info
*, df
->use_regs
, new_size
);
558 df
->eq_use_regs
= XRESIZEVEC (struct df_reg_info
*, df
->eq_use_regs
,
560 df
->def_info
.begin
= XRESIZEVEC (unsigned, df
->def_info
.begin
, new_size
);
561 df
->def_info
.count
= XRESIZEVEC (unsigned, df
->def_info
.count
, new_size
);
562 df
->use_info
.begin
= XRESIZEVEC (unsigned, df
->use_info
.begin
, new_size
);
563 df
->use_info
.count
= XRESIZEVEC (unsigned, df
->use_info
.count
, new_size
);
564 df
->regs_size
= new_size
;
567 for (i
= df
->regs_inited
; i
< max_reg
; i
++)
569 struct df_reg_info
*reg_info
;
571 reg_info
= (struct df_reg_info
*) pool_alloc (problem_data
->reg_pool
);
572 memset (reg_info
, 0, sizeof (struct df_reg_info
));
573 df
->def_regs
[i
] = reg_info
;
574 reg_info
= (struct df_reg_info
*) pool_alloc (problem_data
->reg_pool
);
575 memset (reg_info
, 0, sizeof (struct df_reg_info
));
576 df
->use_regs
[i
] = reg_info
;
577 reg_info
= (struct df_reg_info
*) pool_alloc (problem_data
->reg_pool
);
578 memset (reg_info
, 0, sizeof (struct df_reg_info
));
579 df
->eq_use_regs
[i
] = reg_info
;
580 df
->def_info
.begin
[i
] = 0;
581 df
->def_info
.count
[i
] = 0;
582 df
->use_info
.begin
[i
] = 0;
583 df
->use_info
.count
[i
] = 0;
586 df
->regs_inited
= max_reg
;
590 /* Grow the ref information. */
593 df_grow_ref_info (struct df_ref_info
*ref_info
, unsigned int new_size
)
595 if (ref_info
->refs_size
< new_size
)
597 ref_info
->refs
= XRESIZEVEC (df_ref
, ref_info
->refs
, new_size
);
598 memset (ref_info
->refs
+ ref_info
->refs_size
, 0,
599 (new_size
- ref_info
->refs_size
) *sizeof (df_ref
));
600 ref_info
->refs_size
= new_size
;
605 /* Check and grow the ref information if necessary. This routine
606 guarantees total_size + BITMAP_ADDEND amount of entries in refs
607 array. It updates ref_info->refs_size only and does not change
608 ref_info->total_size. */
611 df_check_and_grow_ref_info (struct df_ref_info
*ref_info
,
612 unsigned bitmap_addend
)
614 if (ref_info
->refs_size
< ref_info
->total_size
+ bitmap_addend
)
616 int new_size
= ref_info
->total_size
+ bitmap_addend
;
617 new_size
+= ref_info
->total_size
/ 4;
618 df_grow_ref_info (ref_info
, new_size
);
623 /* Grow the ref information. If the current size is less than the
624 number of instructions, grow to 25% more than the number of
628 df_grow_insn_info (void)
630 unsigned int new_size
= get_max_uid () + 1;
631 if (DF_INSN_SIZE () < new_size
)
633 new_size
+= new_size
/ 4;
634 df
->insns
= XRESIZEVEC (struct df_insn_info
*, df
->insns
, new_size
);
635 memset (df
->insns
+ df
->insns_size
, 0,
636 (new_size
- DF_INSN_SIZE ()) *sizeof (struct df_insn_info
*));
637 DF_INSN_SIZE () = new_size
;
644 /*----------------------------------------------------------------------------
645 PUBLIC INTERFACES FOR SMALL GRAIN CHANGES TO SCANNING.
646 ----------------------------------------------------------------------------*/
648 /* Rescan all of the block_to_analyze or all of the blocks in the
649 function if df_set_blocks if blocks_to_analyze is NULL; */
652 df_scan_blocks (void)
656 df
->def_info
.ref_order
= DF_REF_ORDER_NO_TABLE
;
657 df
->use_info
.ref_order
= DF_REF_ORDER_NO_TABLE
;
659 df_get_regular_block_artificial_uses (&df
->regular_block_artificial_uses
);
660 df_get_eh_block_artificial_uses (&df
->eh_block_artificial_uses
);
662 bitmap_ior_into (&df
->eh_block_artificial_uses
,
663 &df
->regular_block_artificial_uses
);
665 /* ENTRY and EXIT blocks have special defs/uses. */
666 df_get_entry_block_def_set (df
->entry_block_defs
);
667 df_record_entry_block_defs (df
->entry_block_defs
);
668 df_get_exit_block_use_set (df
->exit_block_uses
);
669 df_record_exit_block_uses (df
->exit_block_uses
);
670 df_set_bb_dirty (BASIC_BLOCK (ENTRY_BLOCK
));
671 df_set_bb_dirty (BASIC_BLOCK (EXIT_BLOCK
));
676 unsigned int bb_index
= bb
->index
;
677 df_bb_refs_record (bb_index
, true);
682 /* Create a new ref of type DF_REF_TYPE for register REG at address
683 LOC within INSN of BB. This function is only used externally. */
686 df_ref_create (rtx reg
, rtx
*loc
, rtx insn
,
688 enum df_ref_type ref_type
,
692 struct df_reg_info
**reg_info
;
693 struct df_ref_info
*ref_info
;
695 df_ref
**ref_rec_ptr
;
696 unsigned int count
= 0;
698 enum df_ref_class cl
;
702 /* You cannot hack artificial refs. */
709 ref
= df_ref_create_structure (cl
, NULL
, reg
, loc
, bb
, DF_INSN_INFO_GET (insn
),
710 ref_type
, ref_flags
);
712 if (DF_REF_REG_DEF_P (ref
))
714 reg_info
= df
->def_regs
;
715 ref_info
= &df
->def_info
;
716 ref_rec_ptr
= &DF_INSN_DEFS (insn
);
717 add_to_table
= ref_info
->ref_order
!= DF_REF_ORDER_NO_TABLE
;
719 else if (DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
)
721 reg_info
= df
->eq_use_regs
;
722 ref_info
= &df
->use_info
;
723 ref_rec_ptr
= &DF_INSN_EQ_USES (insn
);
724 switch (ref_info
->ref_order
)
726 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
727 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
728 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
732 add_to_table
= false;
738 reg_info
= df
->use_regs
;
739 ref_info
= &df
->use_info
;
740 ref_rec_ptr
= &DF_INSN_USES (insn
);
741 add_to_table
= ref_info
->ref_order
!= DF_REF_ORDER_NO_TABLE
;
744 /* Do not add if ref is not in the right blocks. */
745 if (add_to_table
&& df
->analyze_subset
)
746 add_to_table
= bitmap_bit_p (df
->blocks_to_analyze
, bb
->index
);
748 df_install_ref (ref
, reg_info
[DF_REF_REGNO (ref
)], ref_info
, add_to_table
);
751 switch (ref_info
->ref_order
)
753 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
754 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
755 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
756 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED_WITH_NOTES
;
759 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED
;
763 ref_rec
= *ref_rec_ptr
;
770 ref_rec
= *ref_rec_ptr
;
773 ref_rec
= XRESIZEVEC (df_ref
, ref_rec
, count
+2);
774 *ref_rec_ptr
= ref_rec
;
775 ref_rec
[count
] = ref
;
776 ref_rec
[count
+1] = NULL
;
777 qsort (ref_rec
, count
+ 1, sizeof (df_ref
), df_ref_compare
);
781 df_ref
*ref_rec
= XNEWVEC (df_ref
, 2);
784 *ref_rec_ptr
= ref_rec
;
790 fprintf (dump_file
, "adding ref ");
791 df_ref_debug (ref
, dump_file
);
794 /* By adding the ref directly, df_insn_rescan my not find any
795 differences even though the block will have changed. So we need
796 to mark the block dirty ourselves. */
797 if (!DEBUG_INSN_P (DF_REF_INSN (ref
)))
798 df_set_bb_dirty (bb
);
805 /*----------------------------------------------------------------------------
806 UTILITIES TO CREATE AND DESTROY REFS AND CHAINS.
807 ----------------------------------------------------------------------------*/
810 df_free_ref (df_ref ref
)
812 struct df_scan_problem_data
*problem_data
813 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
815 switch (DF_REF_CLASS (ref
))
818 pool_free (problem_data
->ref_base_pool
, ref
);
821 case DF_REF_ARTIFICIAL
:
822 pool_free (problem_data
->ref_artificial_pool
, ref
);
826 pool_free (problem_data
->ref_regular_pool
, ref
);
832 /* Unlink and delete REF at the reg_use, reg_eq_use or reg_def chain.
833 Also delete the def-use or use-def chain if it exists. */
836 df_reg_chain_unlink (df_ref ref
)
838 df_ref next
= DF_REF_NEXT_REG (ref
);
839 df_ref prev
= DF_REF_PREV_REG (ref
);
840 int id
= DF_REF_ID (ref
);
841 struct df_reg_info
*reg_info
;
844 if (DF_REF_REG_DEF_P (ref
))
846 int regno
= DF_REF_REGNO (ref
);
847 reg_info
= DF_REG_DEF_GET (regno
);
848 refs
= df
->def_info
.refs
;
852 if (DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
)
854 reg_info
= DF_REG_EQ_USE_GET (DF_REF_REGNO (ref
));
855 switch (df
->use_info
.ref_order
)
857 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
858 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
859 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
860 refs
= df
->use_info
.refs
;
868 reg_info
= DF_REG_USE_GET (DF_REF_REGNO (ref
));
869 refs
= df
->use_info
.refs
;
875 if (df
->analyze_subset
)
877 if (bitmap_bit_p (df
->blocks_to_analyze
, DF_REF_BBNO (ref
)))
884 /* Delete any def-use or use-def chains that start here. It is
885 possible that there is trash in this field. This happens for
886 insns that have been deleted when rescanning has been deferred
887 and the chain problem has also been deleted. The chain tear down
888 code skips deleted insns. */
889 if (df_chain
&& DF_REF_CHAIN (ref
))
890 df_chain_unlink (ref
);
893 if (DF_REF_FLAGS_IS_SET (ref
, DF_HARD_REG_LIVE
))
895 gcc_assert (DF_REF_REGNO (ref
) < FIRST_PSEUDO_REGISTER
);
896 df
->hard_regs_live_count
[DF_REF_REGNO (ref
)]--;
899 /* Unlink from the reg chain. If there is no prev, this is the
900 first of the list. If not, just join the next and prev. */
902 DF_REF_NEXT_REG (prev
) = next
;
905 gcc_assert (reg_info
->reg_chain
== ref
);
906 reg_info
->reg_chain
= next
;
909 DF_REF_PREV_REG (next
) = prev
;
915 /* Remove REF from VEC. */
918 df_ref_compress_rec (df_ref
**vec_ptr
, df_ref ref
)
920 df_ref
*vec
= *vec_ptr
;
924 while (*vec
&& *vec
!= ref
)
936 *vec_ptr
= df_null_ref_rec
;
941 /* Unlink REF from all def-use/use-def chains, etc. */
944 df_ref_remove (df_ref ref
)
949 fprintf (dump_file
, "removing ref ");
950 df_ref_debug (ref
, dump_file
);
954 if (DF_REF_REG_DEF_P (ref
))
956 if (DF_REF_IS_ARTIFICIAL (ref
))
958 struct df_scan_bb_info
*bb_info
959 = df_scan_get_bb_info (DF_REF_BBNO (ref
));
960 df_ref_compress_rec (&bb_info
->artificial_defs
, ref
);
964 unsigned int uid
= DF_REF_INSN_UID (ref
);
965 struct df_insn_info
*insn_rec
= DF_INSN_UID_GET (uid
);
966 df_ref_compress_rec (&insn_rec
->defs
, ref
);
971 if (DF_REF_IS_ARTIFICIAL (ref
))
973 struct df_scan_bb_info
*bb_info
974 = df_scan_get_bb_info (DF_REF_BBNO (ref
));
975 df_ref_compress_rec (&bb_info
->artificial_uses
, ref
);
979 unsigned int uid
= DF_REF_INSN_UID (ref
);
980 struct df_insn_info
*insn_rec
= DF_INSN_UID_GET (uid
);
982 if (DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
)
983 df_ref_compress_rec (&insn_rec
->eq_uses
, ref
);
985 df_ref_compress_rec (&insn_rec
->uses
, ref
);
989 /* By deleting the ref directly, df_insn_rescan my not find any
990 differences even though the block will have changed. So we need
991 to mark the block dirty ourselves. */
992 if (!DEBUG_INSN_P (DF_REF_INSN (ref
)))
993 df_set_bb_dirty (DF_REF_BB (ref
));
994 df_reg_chain_unlink (ref
);
998 /* Create the insn record for INSN. If there was one there, zero it
1001 struct df_insn_info
*
1002 df_insn_create_insn_record (rtx insn
)
1004 struct df_scan_problem_data
*problem_data
1005 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
1006 struct df_insn_info
*insn_rec
;
1008 df_grow_insn_info ();
1009 insn_rec
= DF_INSN_INFO_GET (insn
);
1012 insn_rec
= (struct df_insn_info
*) pool_alloc (problem_data
->insn_pool
);
1013 DF_INSN_INFO_SET (insn
, insn_rec
);
1015 memset (insn_rec
, 0, sizeof (struct df_insn_info
));
1016 insn_rec
->insn
= insn
;
1021 /* Delete all du chain (DF_REF_CHAIN()) of all refs in the ref chain. */
1024 df_ref_chain_delete_du_chain (df_ref
*ref_rec
)
1028 df_ref ref
= *ref_rec
;
1029 /* CHAIN is allocated by DF_CHAIN. So make sure to
1030 pass df_scan instance for the problem. */
1031 if (DF_REF_CHAIN (ref
))
1032 df_chain_unlink (ref
);
1038 /* Delete all refs in the ref chain. */
1041 df_ref_chain_delete (df_ref
*ref_rec
)
1043 df_ref
*start
= ref_rec
;
1046 df_reg_chain_unlink (*ref_rec
);
1050 /* If the list is empty, it has a special shared element that is not
1057 /* Delete the hardreg chain. */
1060 df_mw_hardreg_chain_delete (struct df_mw_hardreg
**hardregs
)
1062 struct df_scan_problem_data
*problem_data
;
1067 problem_data
= (struct df_scan_problem_data
*) df_scan
->problem_data
;
1071 pool_free (problem_data
->mw_reg_pool
, *hardregs
);
1077 /* Delete all of the refs information from INSN. BB must be passed in
1078 except when called from df_process_deferred_rescans to mark the block
1082 df_insn_delete (basic_block bb
, unsigned int uid
)
1084 struct df_insn_info
*insn_info
= NULL
;
1088 df_grow_bb_info (df_scan
);
1089 df_grow_reg_info ();
1091 /* The block must be marked as dirty now, rather than later as in
1092 df_insn_rescan and df_notes_rescan because it may not be there at
1093 rescanning time and the mark would blow up. */
1095 df_set_bb_dirty (bb
);
1097 insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1099 /* The client has deferred rescanning. */
1100 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1104 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1105 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1106 bitmap_set_bit (&df
->insns_to_delete
, uid
);
1109 fprintf (dump_file
, "deferring deletion of insn with uid = %d.\n", uid
);
1114 fprintf (dump_file
, "deleting insn with uid = %d.\n", uid
);
1116 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1117 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1118 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1121 struct df_scan_problem_data
*problem_data
1122 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
1124 /* In general, notes do not have the insn_info fields
1125 initialized. However, combine deletes insns by changing them
1126 to notes. How clever. So we cannot just check if it is a
1127 valid insn before short circuiting this code, we need to see
1128 if we actually initialized it. */
1129 if (insn_info
->defs
)
1131 df_mw_hardreg_chain_delete (insn_info
->mw_hardregs
);
1135 df_ref_chain_delete_du_chain (insn_info
->defs
);
1136 df_ref_chain_delete_du_chain (insn_info
->uses
);
1137 df_ref_chain_delete_du_chain (insn_info
->eq_uses
);
1140 df_ref_chain_delete (insn_info
->defs
);
1141 df_ref_chain_delete (insn_info
->uses
);
1142 df_ref_chain_delete (insn_info
->eq_uses
);
1144 pool_free (problem_data
->insn_pool
, insn_info
);
1145 DF_INSN_UID_SET (uid
, NULL
);
1150 /* Free all of the refs and the mw_hardregs in COLLECTION_REC. */
1153 df_free_collection_rec (struct df_collection_rec
*collection_rec
)
1156 struct df_scan_problem_data
*problem_data
1157 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
1159 struct df_mw_hardreg
*mw
;
1161 FOR_EACH_VEC_ELT (df_ref
, collection_rec
->def_vec
, ix
, ref
)
1163 FOR_EACH_VEC_ELT (df_ref
, collection_rec
->use_vec
, ix
, ref
)
1165 FOR_EACH_VEC_ELT (df_ref
, collection_rec
->eq_use_vec
, ix
, ref
)
1167 FOR_EACH_VEC_ELT (df_mw_hardreg_ptr
, collection_rec
->mw_vec
, ix
, mw
)
1168 pool_free (problem_data
->mw_reg_pool
, mw
);
1170 VEC_free (df_ref
, stack
, collection_rec
->def_vec
);
1171 VEC_free (df_ref
, stack
, collection_rec
->use_vec
);
1172 VEC_free (df_ref
, stack
, collection_rec
->eq_use_vec
);
1173 VEC_free (df_mw_hardreg_ptr
, stack
, collection_rec
->mw_vec
);
1176 /* Rescan INSN. Return TRUE if the rescanning produced any changes. */
1179 df_insn_rescan (rtx insn
)
1181 unsigned int uid
= INSN_UID (insn
);
1182 struct df_insn_info
*insn_info
= NULL
;
1183 basic_block bb
= BLOCK_FOR_INSN (insn
);
1184 struct df_collection_rec collection_rec
;
1186 if ((!df
) || (!INSN_P (insn
)))
1192 fprintf (dump_file
, "no bb for insn with uid = %d.\n", uid
);
1196 /* The client has disabled rescanning and plans to do it itself. */
1197 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
1200 df_grow_bb_info (df_scan
);
1201 df_grow_reg_info ();
1203 insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1205 /* The client has deferred rescanning. */
1206 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1210 insn_info
= df_insn_create_insn_record (insn
);
1211 insn_info
->defs
= df_null_ref_rec
;
1212 insn_info
->uses
= df_null_ref_rec
;
1213 insn_info
->eq_uses
= df_null_ref_rec
;
1214 insn_info
->mw_hardregs
= df_null_mw_rec
;
1217 fprintf (dump_file
, "deferring rescan insn with uid = %d.\n", uid
);
1219 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1220 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1221 bitmap_set_bit (&df
->insns_to_rescan
, INSN_UID (insn
));
1225 collection_rec
.def_vec
= VEC_alloc (df_ref
, stack
, 128);
1226 collection_rec
.use_vec
= VEC_alloc (df_ref
, stack
, 32);
1227 collection_rec
.eq_use_vec
= VEC_alloc (df_ref
, stack
, 32);
1228 collection_rec
.mw_vec
= VEC_alloc (df_mw_hardreg_ptr
, stack
, 32);
1230 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1231 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1232 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1236 bool the_same
= df_insn_refs_verify (&collection_rec
, bb
, insn
, false);
1237 /* If there's no change, return false. */
1240 df_free_collection_rec (&collection_rec
);
1242 fprintf (dump_file
, "verify found no changes in insn with uid = %d.\n", uid
);
1246 fprintf (dump_file
, "rescanning insn with uid = %d.\n", uid
);
1248 /* There's change - we need to delete the existing info.
1249 Since the insn isn't moved, we can salvage its LUID. */
1250 luid
= DF_INSN_LUID (insn
);
1251 df_insn_delete (NULL
, uid
);
1252 df_insn_create_insn_record (insn
);
1253 DF_INSN_LUID (insn
) = luid
;
1257 struct df_insn_info
*insn_info
= df_insn_create_insn_record (insn
);
1258 df_insn_refs_collect (&collection_rec
, bb
, insn_info
);
1260 fprintf (dump_file
, "scanning new insn with uid = %d.\n", uid
);
1263 df_refs_add_to_chains (&collection_rec
, bb
, insn
);
1264 if (DEBUG_INSN_P (insn
))
1265 df_set_bb_dirty_nonlr (bb
);
1267 df_set_bb_dirty (bb
);
1269 VEC_free (df_ref
, stack
, collection_rec
.def_vec
);
1270 VEC_free (df_ref
, stack
, collection_rec
.use_vec
);
1271 VEC_free (df_ref
, stack
, collection_rec
.eq_use_vec
);
1272 VEC_free (df_mw_hardreg_ptr
, stack
, collection_rec
.mw_vec
);
1277 /* Same as df_insn_rescan, but don't mark the basic block as
1281 df_insn_rescan_debug_internal (rtx insn
)
1283 unsigned int uid
= INSN_UID (insn
);
1284 struct df_insn_info
*insn_info
;
1286 gcc_assert (DEBUG_INSN_P (insn
)
1287 && VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn
)));
1292 insn_info
= DF_INSN_UID_SAFE_GET (INSN_UID (insn
));
1297 fprintf (dump_file
, "deleting debug_insn with uid = %d.\n", uid
);
1299 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
1300 bitmap_clear_bit (&df
->insns_to_rescan
, uid
);
1301 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
1303 if (!insn_info
->defs
)
1306 if (insn_info
->defs
== df_null_ref_rec
1307 && insn_info
->uses
== df_null_ref_rec
1308 && insn_info
->eq_uses
== df_null_ref_rec
1309 && insn_info
->mw_hardregs
== df_null_mw_rec
)
1312 df_mw_hardreg_chain_delete (insn_info
->mw_hardregs
);
1316 df_ref_chain_delete_du_chain (insn_info
->defs
);
1317 df_ref_chain_delete_du_chain (insn_info
->uses
);
1318 df_ref_chain_delete_du_chain (insn_info
->eq_uses
);
1321 df_ref_chain_delete (insn_info
->defs
);
1322 df_ref_chain_delete (insn_info
->uses
);
1323 df_ref_chain_delete (insn_info
->eq_uses
);
1325 insn_info
->defs
= df_null_ref_rec
;
1326 insn_info
->uses
= df_null_ref_rec
;
1327 insn_info
->eq_uses
= df_null_ref_rec
;
1328 insn_info
->mw_hardregs
= df_null_mw_rec
;
1334 /* Rescan all of the insns in the function. Note that the artificial
1335 uses and defs are not touched. This function will destroy def-se
1336 or use-def chains. */
1339 df_insn_rescan_all (void)
1341 bool no_insn_rescan
= false;
1342 bool defer_insn_rescan
= false;
1348 bitmap_initialize (&tmp
, &df_bitmap_obstack
);
1350 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
1352 df_clear_flags (DF_NO_INSN_RESCAN
);
1353 no_insn_rescan
= true;
1356 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1358 df_clear_flags (DF_DEFER_INSN_RESCAN
);
1359 defer_insn_rescan
= true;
1362 bitmap_copy (&tmp
, &df
->insns_to_delete
);
1363 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1365 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1367 df_insn_delete (NULL
, uid
);
1370 bitmap_clear (&tmp
);
1371 bitmap_clear (&df
->insns_to_delete
);
1372 bitmap_clear (&df
->insns_to_rescan
);
1373 bitmap_clear (&df
->insns_to_notes_rescan
);
1378 FOR_BB_INSNS (bb
, insn
)
1380 df_insn_rescan (insn
);
1385 df_set_flags (DF_NO_INSN_RESCAN
);
1386 if (defer_insn_rescan
)
1387 df_set_flags (DF_DEFER_INSN_RESCAN
);
1391 /* Process all of the deferred rescans or deletions. */
1394 df_process_deferred_rescans (void)
1396 bool no_insn_rescan
= false;
1397 bool defer_insn_rescan
= false;
1402 bitmap_initialize (&tmp
, &df_bitmap_obstack
);
1404 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
1406 df_clear_flags (DF_NO_INSN_RESCAN
);
1407 no_insn_rescan
= true;
1410 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
1412 df_clear_flags (DF_DEFER_INSN_RESCAN
);
1413 defer_insn_rescan
= true;
1417 fprintf (dump_file
, "starting the processing of deferred insns\n");
1419 bitmap_copy (&tmp
, &df
->insns_to_delete
);
1420 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1422 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1424 df_insn_delete (NULL
, uid
);
1427 bitmap_copy (&tmp
, &df
->insns_to_rescan
);
1428 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1430 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1432 df_insn_rescan (insn_info
->insn
);
1435 bitmap_copy (&tmp
, &df
->insns_to_notes_rescan
);
1436 EXECUTE_IF_SET_IN_BITMAP (&tmp
, 0, uid
, bi
)
1438 struct df_insn_info
*insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1440 df_notes_rescan (insn_info
->insn
);
1444 fprintf (dump_file
, "ending the processing of deferred insns\n");
1446 bitmap_clear (&tmp
);
1447 bitmap_clear (&df
->insns_to_delete
);
1448 bitmap_clear (&df
->insns_to_rescan
);
1449 bitmap_clear (&df
->insns_to_notes_rescan
);
1452 df_set_flags (DF_NO_INSN_RESCAN
);
1453 if (defer_insn_rescan
)
1454 df_set_flags (DF_DEFER_INSN_RESCAN
);
1456 /* If someone changed regs_ever_live during this pass, fix up the
1457 entry and exit blocks. */
1458 if (df
->redo_entry_and_exit
)
1460 df_update_entry_exit_and_calls ();
1461 df
->redo_entry_and_exit
= false;
1466 /* Count the number of refs. Include the defs if INCLUDE_DEFS. Include
1467 the uses if INCLUDE_USES. Include the eq_uses if
1471 df_count_refs (bool include_defs
, bool include_uses
,
1472 bool include_eq_uses
)
1476 unsigned int m
= df
->regs_inited
;
1478 for (regno
= 0; regno
< m
; regno
++)
1481 size
+= DF_REG_DEF_COUNT (regno
);
1483 size
+= DF_REG_USE_COUNT (regno
);
1484 if (include_eq_uses
)
1485 size
+= DF_REG_EQ_USE_COUNT (regno
);
1491 /* Take build ref table for either the uses or defs from the reg-use
1492 or reg-def chains. This version processes the refs in reg order
1493 which is likely to be best if processing the whole function. */
1496 df_reorganize_refs_by_reg_by_reg (struct df_ref_info
*ref_info
,
1499 bool include_eq_uses
)
1501 unsigned int m
= df
->regs_inited
;
1503 unsigned int offset
= 0;
1506 if (df
->changeable_flags
& DF_NO_HARD_REGS
)
1508 start
= FIRST_PSEUDO_REGISTER
;
1509 memset (ref_info
->begin
, 0, sizeof (int) * FIRST_PSEUDO_REGISTER
);
1510 memset (ref_info
->count
, 0, sizeof (int) * FIRST_PSEUDO_REGISTER
);
1515 ref_info
->total_size
1516 = df_count_refs (include_defs
, include_uses
, include_eq_uses
);
1518 df_check_and_grow_ref_info (ref_info
, 1);
1520 for (regno
= start
; regno
< m
; regno
++)
1523 ref_info
->begin
[regno
] = offset
;
1526 df_ref ref
= DF_REG_DEF_CHAIN (regno
);
1529 ref_info
->refs
[offset
] = ref
;
1530 DF_REF_ID (ref
) = offset
++;
1532 ref
= DF_REF_NEXT_REG (ref
);
1533 gcc_checking_assert (offset
< ref_info
->refs_size
);
1538 df_ref ref
= DF_REG_USE_CHAIN (regno
);
1541 ref_info
->refs
[offset
] = ref
;
1542 DF_REF_ID (ref
) = offset
++;
1544 ref
= DF_REF_NEXT_REG (ref
);
1545 gcc_checking_assert (offset
< ref_info
->refs_size
);
1548 if (include_eq_uses
)
1550 df_ref ref
= DF_REG_EQ_USE_CHAIN (regno
);
1553 ref_info
->refs
[offset
] = ref
;
1554 DF_REF_ID (ref
) = offset
++;
1556 ref
= DF_REF_NEXT_REG (ref
);
1557 gcc_checking_assert (offset
< ref_info
->refs_size
);
1560 ref_info
->count
[regno
] = count
;
1563 /* The bitmap size is not decremented when refs are deleted. So
1564 reset it now that we have squished out all of the empty
1566 ref_info
->table_size
= offset
;
1570 /* Take build ref table for either the uses or defs from the reg-use
1571 or reg-def chains. This version processes the refs in insn order
1572 which is likely to be best if processing some segment of the
1576 df_reorganize_refs_by_reg_by_insn (struct df_ref_info
*ref_info
,
1579 bool include_eq_uses
)
1582 unsigned int bb_index
;
1583 unsigned int m
= df
->regs_inited
;
1584 unsigned int offset
= 0;
1587 = (df
->changeable_flags
& DF_NO_HARD_REGS
) ? FIRST_PSEUDO_REGISTER
: 0;
1589 memset (ref_info
->begin
, 0, sizeof (int) * df
->regs_inited
);
1590 memset (ref_info
->count
, 0, sizeof (int) * df
->regs_inited
);
1592 ref_info
->total_size
= df_count_refs (include_defs
, include_uses
, include_eq_uses
);
1593 df_check_and_grow_ref_info (ref_info
, 1);
1595 EXECUTE_IF_SET_IN_BITMAP (df
->blocks_to_analyze
, 0, bb_index
, bi
)
1597 basic_block bb
= BASIC_BLOCK (bb_index
);
1602 for (ref_rec
= df_get_artificial_defs (bb_index
); *ref_rec
; ref_rec
++)
1604 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1605 ref_info
->count
[regno
]++;
1608 for (ref_rec
= df_get_artificial_uses (bb_index
); *ref_rec
; ref_rec
++)
1610 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1611 ref_info
->count
[regno
]++;
1614 FOR_BB_INSNS (bb
, insn
)
1618 unsigned int uid
= INSN_UID (insn
);
1621 for (ref_rec
= DF_INSN_UID_DEFS (uid
); *ref_rec
; ref_rec
++)
1623 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1624 ref_info
->count
[regno
]++;
1627 for (ref_rec
= DF_INSN_UID_USES (uid
); *ref_rec
; ref_rec
++)
1629 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1630 ref_info
->count
[regno
]++;
1632 if (include_eq_uses
)
1633 for (ref_rec
= DF_INSN_UID_EQ_USES (uid
); *ref_rec
; ref_rec
++)
1635 unsigned int regno
= DF_REF_REGNO (*ref_rec
);
1636 ref_info
->count
[regno
]++;
1642 for (r
= start
; r
< m
; r
++)
1644 ref_info
->begin
[r
] = offset
;
1645 offset
+= ref_info
->count
[r
];
1646 ref_info
->count
[r
] = 0;
1649 EXECUTE_IF_SET_IN_BITMAP (df
->blocks_to_analyze
, 0, bb_index
, bi
)
1651 basic_block bb
= BASIC_BLOCK (bb_index
);
1656 for (ref_rec
= df_get_artificial_defs (bb_index
); *ref_rec
; ref_rec
++)
1658 df_ref ref
= *ref_rec
;
1659 unsigned int regno
= DF_REF_REGNO (ref
);
1663 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1664 DF_REF_ID (ref
) = id
;
1665 ref_info
->refs
[id
] = ref
;
1669 for (ref_rec
= df_get_artificial_uses (bb_index
); *ref_rec
; ref_rec
++)
1671 df_ref ref
= *ref_rec
;
1672 unsigned int regno
= DF_REF_REGNO (ref
);
1676 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1677 DF_REF_ID (ref
) = id
;
1678 ref_info
->refs
[id
] = ref
;
1682 FOR_BB_INSNS (bb
, insn
)
1686 unsigned int uid
= INSN_UID (insn
);
1689 for (ref_rec
= DF_INSN_UID_DEFS (uid
); *ref_rec
; ref_rec
++)
1691 df_ref ref
= *ref_rec
;
1692 unsigned int regno
= DF_REF_REGNO (ref
);
1696 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1697 DF_REF_ID (ref
) = id
;
1698 ref_info
->refs
[id
] = ref
;
1702 for (ref_rec
= DF_INSN_UID_USES (uid
); *ref_rec
; ref_rec
++)
1704 df_ref ref
= *ref_rec
;
1705 unsigned int regno
= DF_REF_REGNO (ref
);
1709 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1710 DF_REF_ID (ref
) = id
;
1711 ref_info
->refs
[id
] = ref
;
1714 if (include_eq_uses
)
1715 for (ref_rec
= DF_INSN_UID_EQ_USES (uid
); *ref_rec
; ref_rec
++)
1717 df_ref ref
= *ref_rec
;
1718 unsigned int regno
= DF_REF_REGNO (ref
);
1722 = ref_info
->begin
[regno
] + ref_info
->count
[regno
]++;
1723 DF_REF_ID (ref
) = id
;
1724 ref_info
->refs
[id
] = ref
;
1731 /* The bitmap size is not decremented when refs are deleted. So
1732 reset it now that we have squished out all of the empty
1735 ref_info
->table_size
= offset
;
1738 /* Take build ref table for either the uses or defs from the reg-use
1739 or reg-def chains. */
1742 df_reorganize_refs_by_reg (struct df_ref_info
*ref_info
,
1745 bool include_eq_uses
)
1747 if (df
->analyze_subset
)
1748 df_reorganize_refs_by_reg_by_insn (ref_info
, include_defs
,
1749 include_uses
, include_eq_uses
);
1751 df_reorganize_refs_by_reg_by_reg (ref_info
, include_defs
,
1752 include_uses
, include_eq_uses
);
1756 /* Add the refs in REF_VEC to the table in REF_INFO starting at OFFSET. */
1758 df_add_refs_to_table (unsigned int offset
,
1759 struct df_ref_info
*ref_info
,
1764 df_ref ref
= *ref_vec
;
1765 if ((!(df
->changeable_flags
& DF_NO_HARD_REGS
))
1766 || (DF_REF_REGNO (ref
) >= FIRST_PSEUDO_REGISTER
))
1768 ref_info
->refs
[offset
] = ref
;
1769 DF_REF_ID (*ref_vec
) = offset
++;
1777 /* Count the number of refs in all of the insns of BB. Include the
1778 defs if INCLUDE_DEFS. Include the uses if INCLUDE_USES. Include the
1779 eq_uses if INCLUDE_EQ_USES. */
1782 df_reorganize_refs_by_insn_bb (basic_block bb
, unsigned int offset
,
1783 struct df_ref_info
*ref_info
,
1784 bool include_defs
, bool include_uses
,
1785 bool include_eq_uses
)
1790 offset
= df_add_refs_to_table (offset
, ref_info
,
1791 df_get_artificial_defs (bb
->index
));
1793 offset
= df_add_refs_to_table (offset
, ref_info
,
1794 df_get_artificial_uses (bb
->index
));
1796 FOR_BB_INSNS (bb
, insn
)
1799 unsigned int uid
= INSN_UID (insn
);
1801 offset
= df_add_refs_to_table (offset
, ref_info
,
1802 DF_INSN_UID_DEFS (uid
));
1804 offset
= df_add_refs_to_table (offset
, ref_info
,
1805 DF_INSN_UID_USES (uid
));
1806 if (include_eq_uses
)
1807 offset
= df_add_refs_to_table (offset
, ref_info
,
1808 DF_INSN_UID_EQ_USES (uid
));
1814 /* Organize the refs by insn into the table in REF_INFO. If
1815 blocks_to_analyze is defined, use that set, otherwise the entire
1816 program. Include the defs if INCLUDE_DEFS. Include the uses if
1817 INCLUDE_USES. Include the eq_uses if INCLUDE_EQ_USES. */
1820 df_reorganize_refs_by_insn (struct df_ref_info
*ref_info
,
1821 bool include_defs
, bool include_uses
,
1822 bool include_eq_uses
)
1825 unsigned int offset
= 0;
1827 ref_info
->total_size
= df_count_refs (include_defs
, include_uses
, include_eq_uses
);
1828 df_check_and_grow_ref_info (ref_info
, 1);
1829 if (df
->blocks_to_analyze
)
1834 EXECUTE_IF_SET_IN_BITMAP (df
->blocks_to_analyze
, 0, index
, bi
)
1836 offset
= df_reorganize_refs_by_insn_bb (BASIC_BLOCK (index
), offset
, ref_info
,
1837 include_defs
, include_uses
,
1841 ref_info
->table_size
= offset
;
1846 offset
= df_reorganize_refs_by_insn_bb (bb
, offset
, ref_info
,
1847 include_defs
, include_uses
,
1849 ref_info
->table_size
= offset
;
1854 /* If the use refs in DF are not organized, reorganize them. */
1857 df_maybe_reorganize_use_refs (enum df_ref_order order
)
1859 if (order
== df
->use_info
.ref_order
)
1864 case DF_REF_ORDER_BY_REG
:
1865 df_reorganize_refs_by_reg (&df
->use_info
, false, true, false);
1868 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
1869 df_reorganize_refs_by_reg (&df
->use_info
, false, true, true);
1872 case DF_REF_ORDER_BY_INSN
:
1873 df_reorganize_refs_by_insn (&df
->use_info
, false, true, false);
1876 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
1877 df_reorganize_refs_by_insn (&df
->use_info
, false, true, true);
1880 case DF_REF_ORDER_NO_TABLE
:
1881 free (df
->use_info
.refs
);
1882 df
->use_info
.refs
= NULL
;
1883 df
->use_info
.refs_size
= 0;
1886 case DF_REF_ORDER_UNORDERED
:
1887 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
1892 df
->use_info
.ref_order
= order
;
1896 /* If the def refs in DF are not organized, reorganize them. */
1899 df_maybe_reorganize_def_refs (enum df_ref_order order
)
1901 if (order
== df
->def_info
.ref_order
)
1906 case DF_REF_ORDER_BY_REG
:
1907 df_reorganize_refs_by_reg (&df
->def_info
, true, false, false);
1910 case DF_REF_ORDER_BY_INSN
:
1911 df_reorganize_refs_by_insn (&df
->def_info
, true, false, false);
1914 case DF_REF_ORDER_NO_TABLE
:
1915 free (df
->def_info
.refs
);
1916 df
->def_info
.refs
= NULL
;
1917 df
->def_info
.refs_size
= 0;
1920 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
1921 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
1922 case DF_REF_ORDER_UNORDERED
:
1923 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
1928 df
->def_info
.ref_order
= order
;
1932 /* Change all of the basic block references in INSN to use the insn's
1933 current basic block. This function is called from routines that move
1934 instructions from one block to another. */
1937 df_insn_change_bb (rtx insn
, basic_block new_bb
)
1939 basic_block old_bb
= BLOCK_FOR_INSN (insn
);
1940 struct df_insn_info
*insn_info
;
1941 unsigned int uid
= INSN_UID (insn
);
1943 if (old_bb
== new_bb
)
1946 set_block_for_insn (insn
, new_bb
);
1952 fprintf (dump_file
, "changing bb of uid %d\n", uid
);
1954 insn_info
= DF_INSN_UID_SAFE_GET (uid
);
1955 if (insn_info
== NULL
)
1958 fprintf (dump_file
, " unscanned insn\n");
1959 df_insn_rescan (insn
);
1966 df_set_bb_dirty (new_bb
);
1970 fprintf (dump_file
, " from %d to %d\n",
1971 old_bb
->index
, new_bb
->index
);
1972 df_set_bb_dirty (old_bb
);
1976 fprintf (dump_file
, " to %d\n", new_bb
->index
);
1980 /* Helper function for df_ref_change_reg_with_loc. */
1983 df_ref_change_reg_with_loc_1 (struct df_reg_info
*old_df
,
1984 struct df_reg_info
*new_df
,
1985 int new_regno
, rtx loc
)
1987 df_ref the_ref
= old_df
->reg_chain
;
1991 if ((!DF_REF_IS_ARTIFICIAL (the_ref
))
1992 && DF_REF_LOC (the_ref
)
1993 && (*DF_REF_LOC (the_ref
) == loc
))
1995 df_ref next_ref
= DF_REF_NEXT_REG (the_ref
);
1996 df_ref prev_ref
= DF_REF_PREV_REG (the_ref
);
1997 df_ref
*ref_vec
, *ref_vec_t
;
1998 struct df_insn_info
*insn_info
= DF_REF_INSN_INFO (the_ref
);
1999 unsigned int count
= 0;
2001 DF_REF_REGNO (the_ref
) = new_regno
;
2002 DF_REF_REG (the_ref
) = regno_reg_rtx
[new_regno
];
2004 /* Pull the_ref out of the old regno chain. */
2006 DF_REF_NEXT_REG (prev_ref
) = next_ref
;
2008 old_df
->reg_chain
= next_ref
;
2010 DF_REF_PREV_REG (next_ref
) = prev_ref
;
2013 /* Put the ref into the new regno chain. */
2014 DF_REF_PREV_REG (the_ref
) = NULL
;
2015 DF_REF_NEXT_REG (the_ref
) = new_df
->reg_chain
;
2016 if (new_df
->reg_chain
)
2017 DF_REF_PREV_REG (new_df
->reg_chain
) = the_ref
;
2018 new_df
->reg_chain
= the_ref
;
2020 if (DF_REF_BB (the_ref
))
2021 df_set_bb_dirty (DF_REF_BB (the_ref
));
2023 /* Need to sort the record again that the ref was in because
2024 the regno is a sorting key. First, find the right
2026 if (DF_REF_FLAGS (the_ref
) & DF_REF_IN_NOTE
)
2027 ref_vec
= insn_info
->eq_uses
;
2029 ref_vec
= insn_info
->uses
;
2031 fprintf (dump_file
, "changing reg in insn %d\n",
2032 DF_REF_INSN_UID (the_ref
));
2034 ref_vec_t
= ref_vec
;
2036 /* Find the length. */
2042 qsort (ref_vec
, count
, sizeof (df_ref
), df_ref_compare
);
2047 the_ref
= DF_REF_NEXT_REG (the_ref
);
2052 /* Change the regno of all refs that contained LOC from OLD_REGNO to
2053 NEW_REGNO. Refs that do not match LOC are not changed which means
2054 that artificial refs are not changed since they have no loc. This
2055 call is to support the SET_REGNO macro. */
2058 df_ref_change_reg_with_loc (int old_regno
, int new_regno
, rtx loc
)
2060 if ((!df
) || (old_regno
== -1) || (old_regno
== new_regno
))
2063 df_grow_reg_info ();
2065 df_ref_change_reg_with_loc_1 (DF_REG_DEF_GET (old_regno
),
2066 DF_REG_DEF_GET (new_regno
), new_regno
, loc
);
2067 df_ref_change_reg_with_loc_1 (DF_REG_USE_GET (old_regno
),
2068 DF_REG_USE_GET (new_regno
), new_regno
, loc
);
2069 df_ref_change_reg_with_loc_1 (DF_REG_EQ_USE_GET (old_regno
),
2070 DF_REG_EQ_USE_GET (new_regno
), new_regno
, loc
);
2074 /* Delete the mw_hardregs that point into the eq_notes. */
2077 df_mw_hardreg_chain_delete_eq_uses (struct df_insn_info
*insn_info
)
2079 struct df_mw_hardreg
**mw_vec
= insn_info
->mw_hardregs
;
2080 unsigned int deleted
= 0;
2081 unsigned int count
= 0;
2082 struct df_scan_problem_data
*problem_data
2083 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2090 if ((*mw_vec
)->flags
& DF_REF_IN_NOTE
)
2092 struct df_mw_hardreg
**temp_vec
= mw_vec
;
2094 pool_free (problem_data
->mw_reg_pool
, *mw_vec
);
2096 /* Shove the remaining ones down one to fill the gap. While
2097 this looks n**2, it is highly unusual to have any mw regs
2098 in eq_notes and the chances of more than one are almost
2102 *temp_vec
= *(temp_vec
+ 1);
2116 df_scan_free_mws_vec (insn_info
->mw_hardregs
);
2117 insn_info
->mw_hardregs
= df_null_mw_rec
;
2124 /* Rescan only the REG_EQUIV/REG_EQUAL notes part of INSN. */
2127 df_notes_rescan (rtx insn
)
2129 struct df_insn_info
*insn_info
;
2130 unsigned int uid
= INSN_UID (insn
);
2135 /* The client has disabled rescanning and plans to do it itself. */
2136 if (df
->changeable_flags
& DF_NO_INSN_RESCAN
)
2139 /* Do nothing if the insn hasn't been emitted yet. */
2140 if (!BLOCK_FOR_INSN (insn
))
2143 df_grow_bb_info (df_scan
);
2144 df_grow_reg_info ();
2146 insn_info
= DF_INSN_UID_SAFE_GET (INSN_UID(insn
));
2148 /* The client has deferred rescanning. */
2149 if (df
->changeable_flags
& DF_DEFER_INSN_RESCAN
)
2153 insn_info
= df_insn_create_insn_record (insn
);
2154 insn_info
->defs
= df_null_ref_rec
;
2155 insn_info
->uses
= df_null_ref_rec
;
2156 insn_info
->eq_uses
= df_null_ref_rec
;
2157 insn_info
->mw_hardregs
= df_null_mw_rec
;
2160 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
2161 /* If the insn is set to be rescanned, it does not need to also
2162 be notes rescanned. */
2163 if (!bitmap_bit_p (&df
->insns_to_rescan
, uid
))
2164 bitmap_set_bit (&df
->insns_to_notes_rescan
, INSN_UID (insn
));
2168 bitmap_clear_bit (&df
->insns_to_delete
, uid
);
2169 bitmap_clear_bit (&df
->insns_to_notes_rescan
, uid
);
2173 basic_block bb
= BLOCK_FOR_INSN (insn
);
2175 struct df_collection_rec collection_rec
;
2176 unsigned int num_deleted
;
2177 unsigned int mw_len
;
2179 memset (&collection_rec
, 0, sizeof (struct df_collection_rec
));
2180 collection_rec
.eq_use_vec
= VEC_alloc (df_ref
, stack
, 32);
2181 collection_rec
.mw_vec
= VEC_alloc (df_mw_hardreg_ptr
, stack
, 32);
2183 num_deleted
= df_mw_hardreg_chain_delete_eq_uses (insn_info
);
2184 df_ref_chain_delete (insn_info
->eq_uses
);
2185 insn_info
->eq_uses
= NULL
;
2187 /* Process REG_EQUIV/REG_EQUAL notes */
2188 for (note
= REG_NOTES (insn
); note
;
2189 note
= XEXP (note
, 1))
2191 switch (REG_NOTE_KIND (note
))
2195 df_uses_record (&collection_rec
,
2196 &XEXP (note
, 0), DF_REF_REG_USE
,
2197 bb
, insn_info
, DF_REF_IN_NOTE
);
2203 /* Find some place to put any new mw_hardregs. */
2204 df_canonize_collection_rec (&collection_rec
);
2205 mw_len
= VEC_length (df_mw_hardreg_ptr
, collection_rec
.mw_vec
);
2208 unsigned int count
= 0;
2209 struct df_mw_hardreg
**mw_rec
= insn_info
->mw_hardregs
;
2218 /* Append to the end of the existing record after
2219 expanding it if necessary. */
2220 if (mw_len
> num_deleted
)
2222 insn_info
->mw_hardregs
=
2223 XRESIZEVEC (struct df_mw_hardreg
*,
2224 insn_info
->mw_hardregs
,
2225 count
+ 1 + mw_len
);
2227 memcpy (&insn_info
->mw_hardregs
[count
],
2228 VEC_address (df_mw_hardreg_ptr
, collection_rec
.mw_vec
),
2229 mw_len
* sizeof (struct df_mw_hardreg
*));
2230 insn_info
->mw_hardregs
[count
+ mw_len
] = NULL
;
2231 qsort (insn_info
->mw_hardregs
, count
+ mw_len
,
2232 sizeof (struct df_mw_hardreg
*), df_mw_compare
);
2236 /* No vector there. */
2237 insn_info
->mw_hardregs
2238 = XNEWVEC (struct df_mw_hardreg
*, 1 + mw_len
);
2239 memcpy (insn_info
->mw_hardregs
,
2240 VEC_address (df_mw_hardreg_ptr
, collection_rec
.mw_vec
),
2241 mw_len
* sizeof (struct df_mw_hardreg
*));
2242 insn_info
->mw_hardregs
[mw_len
] = NULL
;
2245 /* Get rid of the mw_rec so that df_refs_add_to_chains will
2247 VEC_free (df_mw_hardreg_ptr
, stack
, collection_rec
.mw_vec
);
2248 df_refs_add_to_chains (&collection_rec
, bb
, insn
);
2249 VEC_free (df_ref
, stack
, collection_rec
.eq_use_vec
);
2252 df_insn_rescan (insn
);
2257 /*----------------------------------------------------------------------------
2258 Hard core instruction scanning code. No external interfaces here,
2259 just a lot of routines that look inside insns.
2260 ----------------------------------------------------------------------------*/
2263 /* Return true if the contents of two df_ref's are identical.
2264 It ignores DF_REF_MARKER. */
2267 df_ref_equal_p (df_ref ref1
, df_ref ref2
)
2275 if (DF_REF_CLASS (ref1
) != DF_REF_CLASS (ref2
)
2276 || DF_REF_REGNO (ref1
) != DF_REF_REGNO (ref2
)
2277 || DF_REF_REG (ref1
) != DF_REF_REG (ref2
)
2278 || DF_REF_TYPE (ref1
) != DF_REF_TYPE (ref2
)
2279 || ((DF_REF_FLAGS (ref1
) & ~(DF_REF_REG_MARKER
+ DF_REF_MW_HARDREG
))
2280 != (DF_REF_FLAGS (ref2
) & ~(DF_REF_REG_MARKER
+ DF_REF_MW_HARDREG
)))
2281 || DF_REF_BB (ref1
) != DF_REF_BB (ref2
)
2282 || DF_REF_INSN_INFO (ref1
) != DF_REF_INSN_INFO (ref2
))
2285 switch (DF_REF_CLASS (ref1
))
2287 case DF_REF_ARTIFICIAL
:
2291 case DF_REF_REGULAR
:
2292 return DF_REF_LOC (ref1
) == DF_REF_LOC (ref2
);
2301 /* Compare REF1 and REF2 for sorting. This is only called from places
2302 where all of the refs are of the same type, in the same insn, and
2303 have the same bb. So these fields are not checked. */
2306 df_ref_compare (const void *r1
, const void *r2
)
2308 const df_ref ref1
= *(const df_ref
*)r1
;
2309 const df_ref ref2
= *(const df_ref
*)r2
;
2314 if (DF_REF_CLASS (ref1
) != DF_REF_CLASS (ref2
))
2315 return (int)DF_REF_CLASS (ref1
) - (int)DF_REF_CLASS (ref2
);
2317 if (DF_REF_REGNO (ref1
) != DF_REF_REGNO (ref2
))
2318 return (int)DF_REF_REGNO (ref1
) - (int)DF_REF_REGNO (ref2
);
2320 if (DF_REF_TYPE (ref1
) != DF_REF_TYPE (ref2
))
2321 return (int)DF_REF_TYPE (ref1
) - (int)DF_REF_TYPE (ref2
);
2323 if (DF_REF_REG (ref1
) != DF_REF_REG (ref2
))
2324 return (int)DF_REF_ORDER (ref1
) - (int)DF_REF_ORDER (ref2
);
2326 /* Cannot look at the LOC field on artificial refs. */
2327 if (DF_REF_CLASS (ref1
) != DF_REF_ARTIFICIAL
2328 && DF_REF_LOC (ref1
) != DF_REF_LOC (ref2
))
2329 return (int)DF_REF_ORDER (ref1
) - (int)DF_REF_ORDER (ref2
);
2331 if (DF_REF_FLAGS (ref1
) != DF_REF_FLAGS (ref2
))
2333 /* If two refs are identical except that one of them has is from
2334 a mw and one is not, we need to have the one with the mw
2336 if (DF_REF_FLAGS_IS_SET (ref1
, DF_REF_MW_HARDREG
) ==
2337 DF_REF_FLAGS_IS_SET (ref2
, DF_REF_MW_HARDREG
))
2338 return DF_REF_FLAGS (ref1
) - DF_REF_FLAGS (ref2
);
2339 else if (DF_REF_FLAGS_IS_SET (ref1
, DF_REF_MW_HARDREG
))
2345 return (int)DF_REF_ORDER (ref1
) - (int)DF_REF_ORDER (ref2
);
2349 df_swap_refs (VEC(df_ref
,stack
) **ref_vec
, int i
, int j
)
2351 df_ref tmp
= VEC_index (df_ref
, *ref_vec
, i
);
2352 VEC_replace (df_ref
, *ref_vec
, i
, VEC_index (df_ref
, *ref_vec
, j
));
2353 VEC_replace (df_ref
, *ref_vec
, j
, tmp
);
2356 /* Sort and compress a set of refs. */
2359 df_sort_and_compress_refs (VEC(df_ref
,stack
) **ref_vec
)
2363 unsigned int dist
= 0;
2365 count
= VEC_length (df_ref
, *ref_vec
);
2367 /* If there are 1 or 0 elements, there is nothing to do. */
2370 else if (count
== 2)
2372 df_ref r0
= VEC_index (df_ref
, *ref_vec
, 0);
2373 df_ref r1
= VEC_index (df_ref
, *ref_vec
, 1);
2374 if (df_ref_compare (&r0
, &r1
) > 0)
2375 df_swap_refs (ref_vec
, 0, 1);
2379 for (i
= 0; i
< count
- 1; i
++)
2381 df_ref r0
= VEC_index (df_ref
, *ref_vec
, i
);
2382 df_ref r1
= VEC_index (df_ref
, *ref_vec
, i
+ 1);
2383 if (df_ref_compare (&r0
, &r1
) >= 0)
2386 /* If the array is already strictly ordered,
2387 which is the most common case for large COUNT case
2388 (which happens for CALL INSNs),
2389 no need to sort and filter out duplicate.
2390 Simply return the count.
2391 Make sure DF_GET_ADD_REFS adds refs in the increasing order
2392 of DF_REF_COMPARE. */
2395 VEC_qsort (df_ref
, *ref_vec
, df_ref_compare
);
2398 for (i
=0; i
<count
-dist
; i
++)
2400 /* Find the next ref that is not equal to the current ref. */
2401 while (i
+ dist
+ 1 < count
2402 && df_ref_equal_p (VEC_index (df_ref
, *ref_vec
, i
),
2403 VEC_index (df_ref
, *ref_vec
, i
+ dist
+ 1)))
2405 df_free_ref (VEC_index (df_ref
, *ref_vec
, i
+ dist
+ 1));
2408 /* Copy it down to the next position. */
2409 if (dist
&& i
+ dist
+ 1 < count
)
2410 VEC_replace (df_ref
, *ref_vec
, i
+ 1,
2411 VEC_index (df_ref
, *ref_vec
, i
+ dist
+ 1));
2415 VEC_truncate (df_ref
, *ref_vec
, count
);
2419 /* Return true if the contents of two df_ref's are identical.
2420 It ignores DF_REF_MARKER. */
2423 df_mw_equal_p (struct df_mw_hardreg
*mw1
, struct df_mw_hardreg
*mw2
)
2427 return (mw1
== mw2
) ||
2428 (mw1
->mw_reg
== mw2
->mw_reg
2429 && mw1
->type
== mw2
->type
2430 && mw1
->flags
== mw2
->flags
2431 && mw1
->start_regno
== mw2
->start_regno
2432 && mw1
->end_regno
== mw2
->end_regno
);
2436 /* Compare MW1 and MW2 for sorting. */
2439 df_mw_compare (const void *m1
, const void *m2
)
2441 const struct df_mw_hardreg
*const mw1
= *(const struct df_mw_hardreg
*const*)m1
;
2442 const struct df_mw_hardreg
*const mw2
= *(const struct df_mw_hardreg
*const*)m2
;
2447 if (mw1
->type
!= mw2
->type
)
2448 return mw1
->type
- mw2
->type
;
2450 if (mw1
->flags
!= mw2
->flags
)
2451 return mw1
->flags
- mw2
->flags
;
2453 if (mw1
->start_regno
!= mw2
->start_regno
)
2454 return mw1
->start_regno
- mw2
->start_regno
;
2456 if (mw1
->end_regno
!= mw2
->end_regno
)
2457 return mw1
->end_regno
- mw2
->end_regno
;
2459 if (mw1
->mw_reg
!= mw2
->mw_reg
)
2460 return mw1
->mw_order
- mw2
->mw_order
;
2466 /* Sort and compress a set of refs. */
2469 df_sort_and_compress_mws (VEC(df_mw_hardreg_ptr
,stack
) **mw_vec
)
2472 struct df_scan_problem_data
*problem_data
2473 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2475 unsigned int dist
= 0;
2477 count
= VEC_length (df_mw_hardreg_ptr
, *mw_vec
);
2480 else if (count
== 2)
2482 struct df_mw_hardreg
*m0
= VEC_index (df_mw_hardreg_ptr
, *mw_vec
, 0);
2483 struct df_mw_hardreg
*m1
= VEC_index (df_mw_hardreg_ptr
, *mw_vec
, 1);
2484 if (df_mw_compare (&m0
, &m1
) > 0)
2486 struct df_mw_hardreg
*tmp
= VEC_index (df_mw_hardreg_ptr
,
2488 VEC_replace (df_mw_hardreg_ptr
, *mw_vec
, 0,
2489 VEC_index (df_mw_hardreg_ptr
, *mw_vec
, 1));
2490 VEC_replace (df_mw_hardreg_ptr
, *mw_vec
, 1, tmp
);
2494 VEC_qsort (df_mw_hardreg_ptr
, *mw_vec
, df_mw_compare
);
2496 for (i
=0; i
<count
-dist
; i
++)
2498 /* Find the next ref that is not equal to the current ref. */
2499 while (i
+ dist
+ 1 < count
2500 && df_mw_equal_p (VEC_index (df_mw_hardreg_ptr
, *mw_vec
, i
),
2501 VEC_index (df_mw_hardreg_ptr
, *mw_vec
,
2504 pool_free (problem_data
->mw_reg_pool
,
2505 VEC_index (df_mw_hardreg_ptr
, *mw_vec
, i
+ dist
+ 1));
2508 /* Copy it down to the next position. */
2509 if (dist
&& i
+ dist
+ 1 < count
)
2510 VEC_replace (df_mw_hardreg_ptr
, *mw_vec
, i
+ 1,
2511 VEC_index (df_mw_hardreg_ptr
, *mw_vec
, i
+ dist
+ 1));
2515 VEC_truncate (df_mw_hardreg_ptr
, *mw_vec
, count
);
2519 /* Sort and remove duplicates from the COLLECTION_REC. */
2522 df_canonize_collection_rec (struct df_collection_rec
*collection_rec
)
2524 df_sort_and_compress_refs (&collection_rec
->def_vec
);
2525 df_sort_and_compress_refs (&collection_rec
->use_vec
);
2526 df_sort_and_compress_refs (&collection_rec
->eq_use_vec
);
2527 df_sort_and_compress_mws (&collection_rec
->mw_vec
);
2531 /* Add the new df_ref to appropriate reg_info/ref_info chains. */
2534 df_install_ref (df_ref this_ref
,
2535 struct df_reg_info
*reg_info
,
2536 struct df_ref_info
*ref_info
,
2539 unsigned int regno
= DF_REF_REGNO (this_ref
);
2540 /* Add the ref to the reg_{def,use,eq_use} chain. */
2541 df_ref head
= reg_info
->reg_chain
;
2543 reg_info
->reg_chain
= this_ref
;
2546 if (DF_REF_FLAGS_IS_SET (this_ref
, DF_HARD_REG_LIVE
))
2548 gcc_assert (regno
< FIRST_PSEUDO_REGISTER
);
2549 df
->hard_regs_live_count
[regno
]++;
2552 gcc_checking_assert (DF_REF_NEXT_REG (this_ref
) == NULL
2553 && DF_REF_PREV_REG (this_ref
) == NULL
);
2555 DF_REF_NEXT_REG (this_ref
) = head
;
2557 /* We cannot actually link to the head of the chain. */
2558 DF_REF_PREV_REG (this_ref
) = NULL
;
2561 DF_REF_PREV_REG (head
) = this_ref
;
2565 gcc_assert (ref_info
->ref_order
!= DF_REF_ORDER_NO_TABLE
);
2566 df_check_and_grow_ref_info (ref_info
, 1);
2567 DF_REF_ID (this_ref
) = ref_info
->table_size
;
2568 /* Add the ref to the big array of defs. */
2569 ref_info
->refs
[ref_info
->table_size
] = this_ref
;
2570 ref_info
->table_size
++;
2573 DF_REF_ID (this_ref
) = -1;
2575 ref_info
->total_size
++;
2579 /* This function takes one of the groups of refs (defs, uses or
2580 eq_uses) and installs the entire group into the insn. It also adds
2581 each of these refs into the appropriate chains. */
2584 df_install_refs (basic_block bb
,
2585 VEC(df_ref
,stack
)* old_vec
,
2586 struct df_reg_info
**reg_info
,
2587 struct df_ref_info
*ref_info
,
2592 count
= VEC_length (df_ref
, old_vec
);
2595 df_ref
*new_vec
= XNEWVEC (df_ref
, count
+ 1);
2600 switch (ref_info
->ref_order
)
2602 case DF_REF_ORDER_UNORDERED_WITH_NOTES
:
2603 case DF_REF_ORDER_BY_REG_WITH_NOTES
:
2604 case DF_REF_ORDER_BY_INSN_WITH_NOTES
:
2605 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED_WITH_NOTES
;
2606 add_to_table
= true;
2608 case DF_REF_ORDER_UNORDERED
:
2609 case DF_REF_ORDER_BY_REG
:
2610 case DF_REF_ORDER_BY_INSN
:
2611 ref_info
->ref_order
= DF_REF_ORDER_UNORDERED
;
2612 add_to_table
= !is_notes
;
2615 add_to_table
= false;
2619 /* Do not add if ref is not in the right blocks. */
2620 if (add_to_table
&& df
->analyze_subset
)
2621 add_to_table
= bitmap_bit_p (df
->blocks_to_analyze
, bb
->index
);
2623 FOR_EACH_VEC_ELT (df_ref
, old_vec
, ix
, this_ref
)
2625 new_vec
[ix
] = this_ref
;
2626 df_install_ref (this_ref
, reg_info
[DF_REF_REGNO (this_ref
)],
2627 ref_info
, add_to_table
);
2630 new_vec
[count
] = NULL
;
2634 return df_null_ref_rec
;
2638 /* This function takes the mws installs the entire group into the
2641 static struct df_mw_hardreg
**
2642 df_install_mws (VEC(df_mw_hardreg_ptr
,stack
) *old_vec
)
2646 count
= VEC_length (df_mw_hardreg_ptr
, old_vec
);
2649 struct df_mw_hardreg
**new_vec
2650 = XNEWVEC (struct df_mw_hardreg
*, count
+ 1);
2651 memcpy (new_vec
, VEC_address (df_mw_hardreg_ptr
, old_vec
),
2652 sizeof (struct df_mw_hardreg
*) * count
);
2653 new_vec
[count
] = NULL
;
2657 return df_null_mw_rec
;
2661 /* Add a chain of df_refs to appropriate ref chain/reg_info/ref_info
2662 chains and update other necessary information. */
2665 df_refs_add_to_chains (struct df_collection_rec
*collection_rec
,
2666 basic_block bb
, rtx insn
)
2670 struct df_insn_info
*insn_rec
= DF_INSN_INFO_GET (insn
);
2671 /* If there is a vector in the collection rec, add it to the
2672 insn. A null rec is a signal that the caller will handle the
2674 if (collection_rec
->def_vec
)
2676 df_scan_free_ref_vec (insn_rec
->defs
);
2678 = df_install_refs (bb
, collection_rec
->def_vec
,
2680 &df
->def_info
, false);
2682 if (collection_rec
->use_vec
)
2684 df_scan_free_ref_vec (insn_rec
->uses
);
2686 = df_install_refs (bb
, collection_rec
->use_vec
,
2688 &df
->use_info
, false);
2690 if (collection_rec
->eq_use_vec
)
2692 df_scan_free_ref_vec (insn_rec
->eq_uses
);
2694 = df_install_refs (bb
, collection_rec
->eq_use_vec
,
2696 &df
->use_info
, true);
2698 if (collection_rec
->mw_vec
)
2700 df_scan_free_mws_vec (insn_rec
->mw_hardregs
);
2701 insn_rec
->mw_hardregs
2702 = df_install_mws (collection_rec
->mw_vec
);
2707 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb
->index
);
2709 df_scan_free_ref_vec (bb_info
->artificial_defs
);
2710 bb_info
->artificial_defs
2711 = df_install_refs (bb
, collection_rec
->def_vec
,
2713 &df
->def_info
, false);
2714 df_scan_free_ref_vec (bb_info
->artificial_uses
);
2715 bb_info
->artificial_uses
2716 = df_install_refs (bb
, collection_rec
->use_vec
,
2718 &df
->use_info
, false);
2723 /* Allocate a ref and initialize its fields. */
2726 df_ref_create_structure (enum df_ref_class cl
,
2727 struct df_collection_rec
*collection_rec
,
2729 basic_block bb
, struct df_insn_info
*info
,
2730 enum df_ref_type ref_type
,
2733 df_ref this_ref
= NULL
;
2734 int regno
= REGNO (GET_CODE (reg
) == SUBREG
? SUBREG_REG (reg
) : reg
);
2735 struct df_scan_problem_data
*problem_data
2736 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2741 this_ref
= (df_ref
) pool_alloc (problem_data
->ref_base_pool
);
2742 gcc_checking_assert (loc
== NULL
);
2745 case DF_REF_ARTIFICIAL
:
2746 this_ref
= (df_ref
) pool_alloc (problem_data
->ref_artificial_pool
);
2747 this_ref
->artificial_ref
.bb
= bb
;
2748 gcc_checking_assert (loc
== NULL
);
2751 case DF_REF_REGULAR
:
2752 this_ref
= (df_ref
) pool_alloc (problem_data
->ref_regular_pool
);
2753 this_ref
->regular_ref
.loc
= loc
;
2754 gcc_checking_assert (loc
);
2758 DF_REF_CLASS (this_ref
) = cl
;
2759 DF_REF_ID (this_ref
) = -1;
2760 DF_REF_REG (this_ref
) = reg
;
2761 DF_REF_REGNO (this_ref
) = regno
;
2762 DF_REF_TYPE (this_ref
) = ref_type
;
2763 DF_REF_INSN_INFO (this_ref
) = info
;
2764 DF_REF_CHAIN (this_ref
) = NULL
;
2765 DF_REF_FLAGS (this_ref
) = ref_flags
;
2766 DF_REF_NEXT_REG (this_ref
) = NULL
;
2767 DF_REF_PREV_REG (this_ref
) = NULL
;
2768 DF_REF_ORDER (this_ref
) = df
->ref_order
++;
2770 /* We need to clear this bit because fwprop, and in the future
2771 possibly other optimizations sometimes create new refs using ond
2772 refs as the model. */
2773 DF_REF_FLAGS_CLEAR (this_ref
, DF_HARD_REG_LIVE
);
2775 /* See if this ref needs to have DF_HARD_REG_LIVE bit set. */
2776 if ((regno
< FIRST_PSEUDO_REGISTER
)
2777 && (!DF_REF_IS_ARTIFICIAL (this_ref
)))
2779 if (DF_REF_REG_DEF_P (this_ref
))
2781 if (!DF_REF_FLAGS_IS_SET (this_ref
, DF_REF_MAY_CLOBBER
))
2782 DF_REF_FLAGS_SET (this_ref
, DF_HARD_REG_LIVE
);
2784 else if (!(TEST_HARD_REG_BIT (elim_reg_set
, regno
)
2785 && (regno
== FRAME_POINTER_REGNUM
2786 || regno
== ARG_POINTER_REGNUM
)))
2787 DF_REF_FLAGS_SET (this_ref
, DF_HARD_REG_LIVE
);
2792 if (DF_REF_REG_DEF_P (this_ref
))
2793 VEC_safe_push (df_ref
, stack
, collection_rec
->def_vec
, this_ref
);
2794 else if (DF_REF_FLAGS (this_ref
) & DF_REF_IN_NOTE
)
2795 VEC_safe_push (df_ref
, stack
, collection_rec
->eq_use_vec
, this_ref
);
2797 VEC_safe_push (df_ref
, stack
, collection_rec
->use_vec
, this_ref
);
2804 /* Create new references of type DF_REF_TYPE for each part of register REG
2805 at address LOC within INSN of BB. */
2809 df_ref_record (enum df_ref_class cl
,
2810 struct df_collection_rec
*collection_rec
,
2812 basic_block bb
, struct df_insn_info
*insn_info
,
2813 enum df_ref_type ref_type
,
2818 gcc_checking_assert (REG_P (reg
) || GET_CODE (reg
) == SUBREG
);
2820 regno
= REGNO (GET_CODE (reg
) == SUBREG
? SUBREG_REG (reg
) : reg
);
2821 if (regno
< FIRST_PSEUDO_REGISTER
)
2823 struct df_mw_hardreg
*hardreg
= NULL
;
2824 struct df_scan_problem_data
*problem_data
2825 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
2827 unsigned int endregno
;
2830 if (GET_CODE (reg
) == SUBREG
)
2832 regno
+= subreg_regno_offset (regno
, GET_MODE (SUBREG_REG (reg
)),
2833 SUBREG_BYTE (reg
), GET_MODE (reg
));
2834 endregno
= regno
+ subreg_nregs (reg
);
2837 endregno
= END_HARD_REGNO (reg
);
2839 /* If this is a multiword hardreg, we create some extra
2840 datastructures that will enable us to easily build REG_DEAD
2841 and REG_UNUSED notes. */
2842 if ((endregno
!= regno
+ 1) && insn_info
)
2844 /* Sets to a subreg of a multiword register are partial.
2845 Sets to a non-subreg of a multiword register are not. */
2846 if (GET_CODE (reg
) == SUBREG
)
2847 ref_flags
|= DF_REF_PARTIAL
;
2848 ref_flags
|= DF_REF_MW_HARDREG
;
2850 hardreg
= (struct df_mw_hardreg
*) pool_alloc (problem_data
->mw_reg_pool
);
2851 hardreg
->type
= ref_type
;
2852 hardreg
->flags
= ref_flags
;
2853 hardreg
->mw_reg
= reg
;
2854 hardreg
->start_regno
= regno
;
2855 hardreg
->end_regno
= endregno
- 1;
2856 hardreg
->mw_order
= df
->ref_order
++;
2857 VEC_safe_push (df_mw_hardreg_ptr
, stack
, collection_rec
->mw_vec
,
2861 for (i
= regno
; i
< endregno
; i
++)
2863 ref
= df_ref_create_structure (cl
, collection_rec
, regno_reg_rtx
[i
], loc
,
2864 bb
, insn_info
, ref_type
, ref_flags
);
2866 gcc_assert (ORIGINAL_REGNO (DF_REF_REG (ref
)) == i
);
2871 df_ref_create_structure (cl
, collection_rec
, reg
, loc
, bb
, insn_info
,
2872 ref_type
, ref_flags
);
2877 /* A set to a non-paradoxical SUBREG for which the number of word_mode units
2878 covered by the outer mode is smaller than that covered by the inner mode,
2879 is a read-modify-write operation.
2880 This function returns true iff the SUBREG X is such a SUBREG. */
2883 df_read_modify_subreg_p (rtx x
)
2885 unsigned int isize
, osize
;
2886 if (GET_CODE (x
) != SUBREG
)
2888 isize
= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)));
2889 osize
= GET_MODE_SIZE (GET_MODE (x
));
2890 return isize
> osize
2891 && isize
> REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x
)));
2895 /* Process all the registers defined in the rtx, X.
2896 Autoincrement/decrement definitions will be picked up by
2900 df_def_record_1 (struct df_collection_rec
*collection_rec
,
2901 rtx x
, basic_block bb
, struct df_insn_info
*insn_info
,
2907 /* We may recursively call ourselves on EXPR_LIST when dealing with PARALLEL
2909 if (GET_CODE (x
) == EXPR_LIST
|| GET_CODE (x
) == CLOBBER
)
2912 loc
= &SET_DEST (x
);
2915 /* It is legal to have a set destination be a parallel. */
2916 if (GET_CODE (dst
) == PARALLEL
)
2920 for (i
= XVECLEN (dst
, 0) - 1; i
>= 0; i
--)
2922 rtx temp
= XVECEXP (dst
, 0, i
);
2923 if (GET_CODE (temp
) == EXPR_LIST
|| GET_CODE (temp
) == CLOBBER
2924 || GET_CODE (temp
) == SET
)
2925 df_def_record_1 (collection_rec
,
2926 temp
, bb
, insn_info
,
2927 GET_CODE (temp
) == CLOBBER
2928 ? flags
| DF_REF_MUST_CLOBBER
: flags
);
2933 if (GET_CODE (dst
) == STRICT_LOW_PART
)
2935 flags
|= DF_REF_READ_WRITE
| DF_REF_PARTIAL
| DF_REF_STRICT_LOW_PART
;
2937 loc
= &XEXP (dst
, 0);
2941 if (GET_CODE (dst
) == ZERO_EXTRACT
)
2943 flags
|= DF_REF_READ_WRITE
| DF_REF_PARTIAL
| DF_REF_ZERO_EXTRACT
;
2945 loc
= &XEXP (dst
, 0);
2949 /* At this point if we do not have a reg or a subreg, just return. */
2952 df_ref_record (DF_REF_REGULAR
, collection_rec
,
2953 dst
, loc
, bb
, insn_info
, DF_REF_REG_DEF
, flags
);
2955 /* We want to keep sp alive everywhere - by making all
2956 writes to sp also use of sp. */
2957 if (REGNO (dst
) == STACK_POINTER_REGNUM
)
2958 df_ref_record (DF_REF_BASE
, collection_rec
,
2959 dst
, NULL
, bb
, insn_info
, DF_REF_REG_USE
, flags
);
2961 else if (GET_CODE (dst
) == SUBREG
&& REG_P (SUBREG_REG (dst
)))
2963 if (df_read_modify_subreg_p (dst
))
2964 flags
|= DF_REF_READ_WRITE
| DF_REF_PARTIAL
;
2966 flags
|= DF_REF_SUBREG
;
2968 df_ref_record (DF_REF_REGULAR
, collection_rec
,
2969 dst
, loc
, bb
, insn_info
, DF_REF_REG_DEF
, flags
);
2974 /* Process all the registers defined in the pattern rtx, X. */
2977 df_defs_record (struct df_collection_rec
*collection_rec
,
2978 rtx x
, basic_block bb
, struct df_insn_info
*insn_info
,
2981 RTX_CODE code
= GET_CODE (x
);
2983 if (code
== SET
|| code
== CLOBBER
)
2985 /* Mark the single def within the pattern. */
2986 int clobber_flags
= flags
;
2987 clobber_flags
|= (code
== CLOBBER
) ? DF_REF_MUST_CLOBBER
: 0;
2988 df_def_record_1 (collection_rec
, x
, bb
, insn_info
, clobber_flags
);
2990 else if (code
== COND_EXEC
)
2992 df_defs_record (collection_rec
, COND_EXEC_CODE (x
),
2993 bb
, insn_info
, DF_REF_CONDITIONAL
);
2995 else if (code
== PARALLEL
)
2999 /* Mark the multiple defs within the pattern. */
3000 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
3001 df_defs_record (collection_rec
, XVECEXP (x
, 0, i
), bb
, insn_info
, flags
);
3006 /* Process all the registers used in the rtx at address LOC. */
3009 df_uses_record (struct df_collection_rec
*collection_rec
,
3010 rtx
*loc
, enum df_ref_type ref_type
,
3011 basic_block bb
, struct df_insn_info
*insn_info
,
3021 code
= GET_CODE (x
);
3038 /* If we are clobbering a MEM, mark any registers inside the address
3040 if (MEM_P (XEXP (x
, 0)))
3041 df_uses_record (collection_rec
,
3042 &XEXP (XEXP (x
, 0), 0),
3043 DF_REF_REG_MEM_STORE
,
3047 /* If we're clobbering a REG then we have a def so ignore. */
3051 df_uses_record (collection_rec
,
3052 &XEXP (x
, 0), DF_REF_REG_MEM_LOAD
,
3053 bb
, insn_info
, flags
& DF_REF_IN_NOTE
);
3057 /* While we're here, optimize this case. */
3058 flags
|= DF_REF_PARTIAL
;
3059 /* In case the SUBREG is not of a REG, do not optimize. */
3060 if (!REG_P (SUBREG_REG (x
)))
3062 loc
= &SUBREG_REG (x
);
3063 df_uses_record (collection_rec
, loc
, ref_type
, bb
, insn_info
, flags
);
3066 /* ... Fall through ... */
3069 df_ref_record (DF_REF_REGULAR
, collection_rec
,
3070 x
, loc
, bb
, insn_info
,
3077 df_uses_record (collection_rec
,
3078 &XEXP (x
, 1), ref_type
, bb
, insn_info
, flags
);
3079 df_uses_record (collection_rec
,
3080 &XEXP (x
, 2), ref_type
, bb
, insn_info
, flags
);
3082 /* If the parameters to the zero or sign extract are
3083 constants, strip them off and recurse, otherwise there is
3084 no information that we can gain from this operation. */
3085 if (code
== ZERO_EXTRACT
)
3086 flags
|= DF_REF_ZERO_EXTRACT
;
3088 flags
|= DF_REF_SIGN_EXTRACT
;
3090 df_uses_record (collection_rec
,
3091 &XEXP (x
, 0), ref_type
, bb
, insn_info
, flags
);
3098 rtx dst
= SET_DEST (x
);
3099 gcc_assert (!(flags
& DF_REF_IN_NOTE
));
3100 df_uses_record (collection_rec
,
3101 &SET_SRC (x
), DF_REF_REG_USE
, bb
, insn_info
, flags
);
3103 switch (GET_CODE (dst
))
3106 if (df_read_modify_subreg_p (dst
))
3108 df_uses_record (collection_rec
, &SUBREG_REG (dst
),
3109 DF_REF_REG_USE
, bb
, insn_info
,
3110 flags
| DF_REF_READ_WRITE
| DF_REF_SUBREG
);
3121 df_uses_record (collection_rec
, &XEXP (dst
, 0),
3122 DF_REF_REG_MEM_STORE
, bb
, insn_info
, flags
);
3124 case STRICT_LOW_PART
:
3126 rtx
*temp
= &XEXP (dst
, 0);
3127 /* A strict_low_part uses the whole REG and not just the
3129 dst
= XEXP (dst
, 0);
3130 df_uses_record (collection_rec
,
3131 (GET_CODE (dst
) == SUBREG
) ? &SUBREG_REG (dst
) : temp
,
3132 DF_REF_REG_USE
, bb
, insn_info
,
3133 DF_REF_READ_WRITE
| DF_REF_STRICT_LOW_PART
);
3138 df_uses_record (collection_rec
, &XEXP (dst
, 1),
3139 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3140 df_uses_record (collection_rec
, &XEXP (dst
, 2),
3141 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3142 if (GET_CODE (XEXP (dst
,0)) == MEM
)
3143 df_uses_record (collection_rec
, &XEXP (dst
, 0),
3144 DF_REF_REG_USE
, bb
, insn_info
,
3147 df_uses_record (collection_rec
, &XEXP (dst
, 0),
3148 DF_REF_REG_USE
, bb
, insn_info
,
3149 DF_REF_READ_WRITE
| DF_REF_ZERO_EXTRACT
);
3163 case UNSPEC_VOLATILE
:
3167 /* Traditional and volatile asm instructions must be
3168 considered to use and clobber all hard registers, all
3169 pseudo-registers and all of memory. So must TRAP_IF and
3170 UNSPEC_VOLATILE operations.
3172 Consider for instance a volatile asm that changes the fpu
3173 rounding mode. An insn should not be moved across this
3174 even if it only uses pseudo-regs because it might give an
3175 incorrectly rounded result.
3177 However, flow.c's liveness computation did *not* do this,
3178 giving the reasoning as " ?!? Unfortunately, marking all
3179 hard registers as live causes massive problems for the
3180 register allocator and marking all pseudos as live creates
3181 mountains of uninitialized variable warnings."
3183 In order to maintain the status quo with regard to liveness
3184 and uses, we do what flow.c did and just mark any regs we
3185 can find in ASM_OPERANDS as used. In global asm insns are
3186 scanned and regs_asm_clobbered is filled out.
3188 For all ASM_OPERANDS, we must traverse the vector of input
3189 operands. We can not just fall through here since then we
3190 would be confused by the ASM_INPUT rtx inside ASM_OPERANDS,
3191 which do not indicate traditional asms unlike their normal
3193 if (code
== ASM_OPERANDS
)
3197 for (j
= 0; j
< ASM_OPERANDS_INPUT_LENGTH (x
); j
++)
3198 df_uses_record (collection_rec
, &ASM_OPERANDS_INPUT (x
, j
),
3199 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3206 df_uses_record (collection_rec
,
3207 &PAT_VAR_LOCATION_LOC (x
),
3208 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3217 gcc_assert (!DEBUG_INSN_P (insn_info
->insn
));
3218 /* Catch the def of the register being modified. */
3219 df_ref_record (DF_REF_REGULAR
, collection_rec
, XEXP (x
, 0), &XEXP (x
, 0),
3222 flags
| DF_REF_READ_WRITE
| DF_REF_PRE_POST_MODIFY
);
3224 /* ... Fall through to handle uses ... */
3230 /* Recursively scan the operands of this expression. */
3232 const char *fmt
= GET_RTX_FORMAT (code
);
3235 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
3239 /* Tail recursive case: save a function call level. */
3245 df_uses_record (collection_rec
, &XEXP (x
, i
), ref_type
,
3246 bb
, insn_info
, flags
);
3248 else if (fmt
[i
] == 'E')
3251 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3252 df_uses_record (collection_rec
,
3253 &XVECEXP (x
, i
, j
), ref_type
,
3254 bb
, insn_info
, flags
);
3263 /* For all DF_REF_CONDITIONAL defs, add a corresponding uses. */
3266 df_get_conditional_uses (struct df_collection_rec
*collection_rec
)
3271 FOR_EACH_VEC_ELT (df_ref
, collection_rec
->def_vec
, ix
, ref
)
3273 if (DF_REF_FLAGS_IS_SET (ref
, DF_REF_CONDITIONAL
))
3277 use
= df_ref_create_structure (DF_REF_CLASS (ref
), collection_rec
, DF_REF_REG (ref
),
3278 DF_REF_LOC (ref
), DF_REF_BB (ref
),
3279 DF_REF_INSN_INFO (ref
), DF_REF_REG_USE
,
3280 DF_REF_FLAGS (ref
) & ~DF_REF_CONDITIONAL
);
3281 DF_REF_REGNO (use
) = DF_REF_REGNO (ref
);
3287 /* Get call's extra defs and uses. */
3290 df_get_call_refs (struct df_collection_rec
* collection_rec
,
3292 struct df_insn_info
*insn_info
,
3298 bool is_sibling_call
;
3301 bitmap_head defs_generated
;
3303 bitmap_initialize (&defs_generated
, &df_bitmap_obstack
);
3305 /* Do not generate clobbers for registers that are the result of the
3306 call. This causes ordering problems in the chain building code
3307 depending on which def is seen first. */
3308 FOR_EACH_VEC_ELT (df_ref
, collection_rec
->def_vec
, i
, def
)
3309 bitmap_set_bit (&defs_generated
, DF_REF_REGNO (def
));
3311 /* Record the registers used to pass arguments, and explicitly
3312 noted as clobbered. */
3313 for (note
= CALL_INSN_FUNCTION_USAGE (insn_info
->insn
); note
;
3314 note
= XEXP (note
, 1))
3316 if (GET_CODE (XEXP (note
, 0)) == USE
)
3317 df_uses_record (collection_rec
, &XEXP (XEXP (note
, 0), 0),
3318 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3319 else if (GET_CODE (XEXP (note
, 0)) == CLOBBER
)
3321 if (REG_P (XEXP (XEXP (note
, 0), 0)))
3323 unsigned int regno
= REGNO (XEXP (XEXP (note
, 0), 0));
3324 if (!bitmap_bit_p (&defs_generated
, regno
))
3325 df_defs_record (collection_rec
, XEXP (note
, 0), bb
,
3329 df_uses_record (collection_rec
, &XEXP (note
, 0),
3330 DF_REF_REG_USE
, bb
, insn_info
, flags
);
3334 /* The stack ptr is used (honorarily) by a CALL insn. */
3335 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[STACK_POINTER_REGNUM
],
3336 NULL
, bb
, insn_info
, DF_REF_REG_USE
,
3337 DF_REF_CALL_STACK_USAGE
| flags
);
3339 /* Calls may also reference any of the global registers,
3340 so they are recorded as used. */
3341 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3344 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[i
],
3345 NULL
, bb
, insn_info
, DF_REF_REG_USE
, flags
);
3346 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[i
],
3347 NULL
, bb
, insn_info
, DF_REF_REG_DEF
, flags
);
3350 is_sibling_call
= SIBLING_CALL_P (insn_info
->insn
);
3351 EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset
, 0, ui
, bi
)
3353 if (!global_regs
[ui
]
3354 && (!bitmap_bit_p (&defs_generated
, ui
))
3355 && (!is_sibling_call
3356 || !bitmap_bit_p (df
->exit_block_uses
, ui
)
3357 || refers_to_regno_p (ui
, ui
+1,
3358 crtl
->return_rtx
, NULL
)))
3359 df_ref_record (DF_REF_BASE
, collection_rec
, regno_reg_rtx
[ui
],
3360 NULL
, bb
, insn_info
, DF_REF_REG_DEF
,
3361 DF_REF_MAY_CLOBBER
| flags
);
3364 bitmap_clear (&defs_generated
);
3368 /* Collect all refs in the INSN. This function is free of any
3369 side-effect - it will create and return a lists of df_ref's in the
3370 COLLECTION_REC without putting those refs into existing ref chains
3374 df_insn_refs_collect (struct df_collection_rec
* collection_rec
,
3375 basic_block bb
, struct df_insn_info
*insn_info
)
3378 bool is_cond_exec
= (GET_CODE (PATTERN (insn_info
->insn
)) == COND_EXEC
);
3380 /* Clear out the collection record. */
3381 VEC_truncate (df_ref
, collection_rec
->def_vec
, 0);
3382 VEC_truncate (df_ref
, collection_rec
->use_vec
, 0);
3383 VEC_truncate (df_ref
, collection_rec
->eq_use_vec
, 0);
3384 VEC_truncate (df_mw_hardreg_ptr
, collection_rec
->mw_vec
, 0);
3386 /* Record register defs. */
3387 df_defs_record (collection_rec
, PATTERN (insn_info
->insn
), bb
, insn_info
, 0);
3389 /* Process REG_EQUIV/REG_EQUAL notes. */
3390 for (note
= REG_NOTES (insn_info
->insn
); note
;
3391 note
= XEXP (note
, 1))
3393 switch (REG_NOTE_KIND (note
))
3397 df_uses_record (collection_rec
,
3398 &XEXP (note
, 0), DF_REF_REG_USE
,
3399 bb
, insn_info
, DF_REF_IN_NOTE
);
3401 case REG_NON_LOCAL_GOTO
:
3402 /* The frame ptr is used by a non-local goto. */
3403 df_ref_record (DF_REF_BASE
, collection_rec
,
3404 regno_reg_rtx
[FRAME_POINTER_REGNUM
],
3405 NULL
, bb
, insn_info
,
3407 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3408 df_ref_record (DF_REF_BASE
, collection_rec
,
3409 regno_reg_rtx
[HARD_FRAME_POINTER_REGNUM
],
3410 NULL
, bb
, insn_info
,
3419 if (CALL_P (insn_info
->insn
))
3420 df_get_call_refs (collection_rec
, bb
, insn_info
,
3421 (is_cond_exec
) ? DF_REF_CONDITIONAL
: 0);
3423 /* Record the register uses. */
3424 df_uses_record (collection_rec
,
3425 &PATTERN (insn_info
->insn
), DF_REF_REG_USE
, bb
, insn_info
, 0);
3427 /* DF_REF_CONDITIONAL needs corresponding USES. */
3429 df_get_conditional_uses (collection_rec
);
3431 df_canonize_collection_rec (collection_rec
);
3434 /* Recompute the luids for the insns in BB. */
3437 df_recompute_luids (basic_block bb
)
3442 df_grow_insn_info ();
3444 /* Scan the block an insn at a time from beginning to end. */
3445 FOR_BB_INSNS (bb
, insn
)
3447 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
3448 /* Inserting labels does not always trigger the incremental
3452 gcc_assert (!INSN_P (insn
));
3453 insn_info
= df_insn_create_insn_record (insn
);
3456 DF_INSN_INFO_LUID (insn_info
) = luid
;
3463 /* Collect all artificial refs at the block level for BB and add them
3464 to COLLECTION_REC. */
3467 df_bb_refs_collect (struct df_collection_rec
*collection_rec
, basic_block bb
)
3469 VEC_truncate (df_ref
, collection_rec
->def_vec
, 0);
3470 VEC_truncate (df_ref
, collection_rec
->use_vec
, 0);
3471 VEC_truncate (df_ref
, collection_rec
->eq_use_vec
, 0);
3472 VEC_truncate (df_mw_hardreg_ptr
, collection_rec
->mw_vec
, 0);
3474 if (bb
->index
== ENTRY_BLOCK
)
3476 df_entry_block_defs_collect (collection_rec
, df
->entry_block_defs
);
3479 else if (bb
->index
== EXIT_BLOCK
)
3481 df_exit_block_uses_collect (collection_rec
, df
->exit_block_uses
);
3485 #ifdef EH_RETURN_DATA_REGNO
3486 if (bb_has_eh_pred (bb
))
3489 /* Mark the registers that will contain data for the handler. */
3492 unsigned regno
= EH_RETURN_DATA_REGNO (i
);
3493 if (regno
== INVALID_REGNUM
)
3495 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[regno
], NULL
,
3496 bb
, NULL
, DF_REF_REG_DEF
, DF_REF_AT_TOP
);
3501 /* Add the hard_frame_pointer if this block is the target of a
3503 if (bb
->flags
& BB_NON_LOCAL_GOTO_TARGET
)
3504 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, hard_frame_pointer_rtx
, NULL
,
3505 bb
, NULL
, DF_REF_REG_DEF
, DF_REF_AT_TOP
);
3507 /* Add the artificial uses. */
3508 if (bb
->index
>= NUM_FIXED_BLOCKS
)
3512 bitmap au
= bb_has_eh_pred (bb
)
3513 ? &df
->eh_block_artificial_uses
3514 : &df
->regular_block_artificial_uses
;
3516 EXECUTE_IF_SET_IN_BITMAP (au
, 0, regno
, bi
)
3518 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[regno
], NULL
,
3519 bb
, NULL
, DF_REF_REG_USE
, 0);
3523 df_canonize_collection_rec (collection_rec
);
3527 /* Record all the refs within the basic block BB_INDEX and scan the instructions if SCAN_INSNS. */
3530 df_bb_refs_record (int bb_index
, bool scan_insns
)
3532 basic_block bb
= BASIC_BLOCK (bb_index
);
3535 struct df_collection_rec collection_rec
;
3540 df_grow_bb_info (df_scan
);
3541 collection_rec
.def_vec
= VEC_alloc (df_ref
, stack
, 128);
3542 collection_rec
.use_vec
= VEC_alloc (df_ref
, stack
, 32);
3543 collection_rec
.eq_use_vec
= VEC_alloc (df_ref
, stack
, 32);
3544 collection_rec
.mw_vec
= VEC_alloc (df_mw_hardreg_ptr
, stack
, 32);
3547 /* Scan the block an insn at a time from beginning to end. */
3548 FOR_BB_INSNS (bb
, insn
)
3550 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
3551 gcc_assert (!insn_info
);
3553 insn_info
= df_insn_create_insn_record (insn
);
3556 /* Record refs within INSN. */
3557 DF_INSN_INFO_LUID (insn_info
) = luid
++;
3558 df_insn_refs_collect (&collection_rec
, bb
, DF_INSN_INFO_GET (insn
));
3559 df_refs_add_to_chains (&collection_rec
, bb
, insn
);
3561 DF_INSN_INFO_LUID (insn_info
) = luid
;
3564 /* Other block level artificial refs */
3565 df_bb_refs_collect (&collection_rec
, bb
);
3566 df_refs_add_to_chains (&collection_rec
, bb
, NULL
);
3568 VEC_free (df_ref
, stack
, collection_rec
.def_vec
);
3569 VEC_free (df_ref
, stack
, collection_rec
.use_vec
);
3570 VEC_free (df_ref
, stack
, collection_rec
.eq_use_vec
);
3571 VEC_free (df_mw_hardreg_ptr
, stack
, collection_rec
.mw_vec
);
3573 /* Now that the block has been processed, set the block as dirty so
3574 LR and LIVE will get it processed. */
3575 df_set_bb_dirty (bb
);
3579 /* Get the artificial use set for a regular (i.e. non-exit/non-entry)
3583 df_get_regular_block_artificial_uses (bitmap regular_block_artificial_uses
)
3589 bitmap_clear (regular_block_artificial_uses
);
3591 if (reload_completed
)
3593 if (frame_pointer_needed
)
3594 bitmap_set_bit (regular_block_artificial_uses
, HARD_FRAME_POINTER_REGNUM
);
3597 /* Before reload, there are a few registers that must be forced
3598 live everywhere -- which might not already be the case for
3599 blocks within infinite loops. */
3601 /* Any reference to any pseudo before reload is a potential
3602 reference of the frame pointer. */
3603 bitmap_set_bit (regular_block_artificial_uses
, FRAME_POINTER_REGNUM
);
3605 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3606 bitmap_set_bit (regular_block_artificial_uses
, HARD_FRAME_POINTER_REGNUM
);
3609 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3610 /* Pseudos with argument area equivalences may require
3611 reloading via the argument pointer. */
3612 if (fixed_regs
[ARG_POINTER_REGNUM
])
3613 bitmap_set_bit (regular_block_artificial_uses
, ARG_POINTER_REGNUM
);
3616 /* Any constant, or pseudo with constant equivalences, may
3617 require reloading from memory using the pic register. */
3618 if ((unsigned) PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
3619 && fixed_regs
[PIC_OFFSET_TABLE_REGNUM
])
3620 bitmap_set_bit (regular_block_artificial_uses
, PIC_OFFSET_TABLE_REGNUM
);
3622 /* The all-important stack pointer must always be live. */
3623 bitmap_set_bit (regular_block_artificial_uses
, STACK_POINTER_REGNUM
);
3626 /* EH_USES registers are used:
3627 1) at all insns that might throw (calls or with -fnon-call-exceptions
3630 3) to support backtraces and/or debugging, anywhere between their
3631 initialization and where they the saved registers are restored
3632 from them, including the cases where we don't reach the epilogue
3633 (noreturn call or infinite loop). */
3634 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3636 bitmap_set_bit (regular_block_artificial_uses
, i
);
3641 /* Get the artificial use set for an eh block. */
3644 df_get_eh_block_artificial_uses (bitmap eh_block_artificial_uses
)
3646 bitmap_clear (eh_block_artificial_uses
);
3648 /* The following code (down thru the arg_pointer setting APPEARS
3649 to be necessary because there is nothing that actually
3650 describes what the exception handling code may actually need
3652 if (reload_completed
)
3654 if (frame_pointer_needed
)
3656 bitmap_set_bit (eh_block_artificial_uses
, FRAME_POINTER_REGNUM
);
3657 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3658 bitmap_set_bit (eh_block_artificial_uses
, HARD_FRAME_POINTER_REGNUM
);
3661 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3662 if (fixed_regs
[ARG_POINTER_REGNUM
])
3663 bitmap_set_bit (eh_block_artificial_uses
, ARG_POINTER_REGNUM
);
3670 /*----------------------------------------------------------------------------
3671 Specialized hard register scanning functions.
3672 ----------------------------------------------------------------------------*/
3675 /* Mark a register in SET. Hard registers in large modes get all
3676 of their component registers set as well. */
3679 df_mark_reg (rtx reg
, void *vset
)
3681 bitmap set
= (bitmap
) vset
;
3682 int regno
= REGNO (reg
);
3684 gcc_assert (GET_MODE (reg
) != BLKmode
);
3686 if (regno
< FIRST_PSEUDO_REGISTER
)
3688 int n
= hard_regno_nregs
[regno
][GET_MODE (reg
)];
3689 bitmap_set_range (set
, regno
, n
);
3692 bitmap_set_bit (set
, regno
);
3696 /* Set the bit for regs that are considered being defined at the entry. */
3699 df_get_entry_block_def_set (bitmap entry_block_defs
)
3704 bitmap_clear (entry_block_defs
);
3706 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3708 if (FUNCTION_ARG_REGNO_P (i
))
3709 #ifdef INCOMING_REGNO
3710 bitmap_set_bit (entry_block_defs
, INCOMING_REGNO (i
));
3712 bitmap_set_bit (entry_block_defs
, i
);
3716 /* The always important stack pointer. */
3717 bitmap_set_bit (entry_block_defs
, STACK_POINTER_REGNUM
);
3719 /* Once the prologue has been generated, all of these registers
3720 should just show up in the first regular block. */
3721 if (HAVE_prologue
&& epilogue_completed
)
3723 /* Defs for the callee saved registers are inserted so that the
3724 pushes have some defining location. */
3725 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3726 if ((call_used_regs
[i
] == 0) && (df_regs_ever_live_p (i
)))
3727 bitmap_set_bit (entry_block_defs
, i
);
3730 r
= targetm
.calls
.struct_value_rtx (current_function_decl
, true);
3732 bitmap_set_bit (entry_block_defs
, REGNO (r
));
3734 /* If the function has an incoming STATIC_CHAIN, it has to show up
3735 in the entry def set. */
3736 r
= targetm
.calls
.static_chain (current_function_decl
, true);
3738 bitmap_set_bit (entry_block_defs
, REGNO (r
));
3740 if ((!reload_completed
) || frame_pointer_needed
)
3742 /* Any reference to any pseudo before reload is a potential
3743 reference of the frame pointer. */
3744 bitmap_set_bit (entry_block_defs
, FRAME_POINTER_REGNUM
);
3745 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3746 /* If they are different, also mark the hard frame pointer as live. */
3747 if (!LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM
))
3748 bitmap_set_bit (entry_block_defs
, HARD_FRAME_POINTER_REGNUM
);
3752 /* These registers are live everywhere. */
3753 if (!reload_completed
)
3755 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3756 /* Pseudos with argument area equivalences may require
3757 reloading via the argument pointer. */
3758 if (fixed_regs
[ARG_POINTER_REGNUM
])
3759 bitmap_set_bit (entry_block_defs
, ARG_POINTER_REGNUM
);
3762 #ifdef PIC_OFFSET_TABLE_REGNUM
3763 /* Any constant, or pseudo with constant equivalences, may
3764 require reloading from memory using the pic register. */
3765 if ((unsigned) PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
3766 && fixed_regs
[PIC_OFFSET_TABLE_REGNUM
])
3767 bitmap_set_bit (entry_block_defs
, PIC_OFFSET_TABLE_REGNUM
);
3771 #ifdef INCOMING_RETURN_ADDR_RTX
3772 if (REG_P (INCOMING_RETURN_ADDR_RTX
))
3773 bitmap_set_bit (entry_block_defs
, REGNO (INCOMING_RETURN_ADDR_RTX
));
3776 targetm
.extra_live_on_entry (entry_block_defs
);
3780 /* Return the (conservative) set of hard registers that are defined on
3781 entry to the function.
3782 It uses df->entry_block_defs to determine which register
3783 reference to include. */
3786 df_entry_block_defs_collect (struct df_collection_rec
*collection_rec
,
3787 bitmap entry_block_defs
)
3792 EXECUTE_IF_SET_IN_BITMAP (entry_block_defs
, 0, i
, bi
)
3794 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[i
], NULL
,
3795 ENTRY_BLOCK_PTR
, NULL
, DF_REF_REG_DEF
, 0);
3798 df_canonize_collection_rec (collection_rec
);
3802 /* Record the (conservative) set of hard registers that are defined on
3803 entry to the function. */
3806 df_record_entry_block_defs (bitmap entry_block_defs
)
3808 struct df_collection_rec collection_rec
;
3809 memset (&collection_rec
, 0, sizeof (struct df_collection_rec
));
3810 collection_rec
.def_vec
= VEC_alloc (df_ref
, stack
, FIRST_PSEUDO_REGISTER
);
3811 df_entry_block_defs_collect (&collection_rec
, entry_block_defs
);
3813 /* Process bb_refs chain */
3814 df_refs_add_to_chains (&collection_rec
, BASIC_BLOCK (ENTRY_BLOCK
), NULL
);
3815 VEC_free (df_ref
, stack
, collection_rec
.def_vec
);
3819 /* Update the defs in the entry block. */
3822 df_update_entry_block_defs (void)
3825 bool changed
= false;
3827 bitmap_initialize (&refs
, &df_bitmap_obstack
);
3828 df_get_entry_block_def_set (&refs
);
3829 if (df
->entry_block_defs
)
3831 if (!bitmap_equal_p (df
->entry_block_defs
, &refs
))
3833 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (ENTRY_BLOCK
);
3834 df_ref_chain_delete_du_chain (bb_info
->artificial_defs
);
3835 df_ref_chain_delete (bb_info
->artificial_defs
);
3836 bb_info
->artificial_defs
= NULL
;
3842 struct df_scan_problem_data
*problem_data
3843 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
3845 df
->entry_block_defs
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
3851 df_record_entry_block_defs (&refs
);
3852 bitmap_copy (df
->entry_block_defs
, &refs
);
3853 df_set_bb_dirty (BASIC_BLOCK (ENTRY_BLOCK
));
3855 bitmap_clear (&refs
);
3859 /* Set the bit for regs that are considered being used at the exit. */
3862 df_get_exit_block_use_set (bitmap exit_block_uses
)
3866 bitmap_clear (exit_block_uses
);
3868 /* Stack pointer is always live at the exit. */
3869 bitmap_set_bit (exit_block_uses
, STACK_POINTER_REGNUM
);
3871 /* Mark the frame pointer if needed at the end of the function.
3872 If we end up eliminating it, it will be removed from the live
3873 list of each basic block by reload. */
3875 if ((!reload_completed
) || frame_pointer_needed
)
3877 bitmap_set_bit (exit_block_uses
, FRAME_POINTER_REGNUM
);
3878 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
3879 /* If they are different, also mark the hard frame pointer as live. */
3880 if (!LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM
))
3881 bitmap_set_bit (exit_block_uses
, HARD_FRAME_POINTER_REGNUM
);
3885 /* Many architectures have a GP register even without flag_pic.
3886 Assume the pic register is not in use, or will be handled by
3887 other means, if it is not fixed. */
3888 if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
3889 && (unsigned) PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
3890 && fixed_regs
[PIC_OFFSET_TABLE_REGNUM
])
3891 bitmap_set_bit (exit_block_uses
, PIC_OFFSET_TABLE_REGNUM
);
3893 /* Mark all global registers, and all registers used by the
3894 epilogue as being live at the end of the function since they
3895 may be referenced by our caller. */
3896 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3897 if (global_regs
[i
] || EPILOGUE_USES (i
))
3898 bitmap_set_bit (exit_block_uses
, i
);
3900 if (HAVE_epilogue
&& epilogue_completed
)
3902 /* Mark all call-saved registers that we actually used. */
3903 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3904 if (df_regs_ever_live_p (i
) && !LOCAL_REGNO (i
)
3905 && !TEST_HARD_REG_BIT (regs_invalidated_by_call
, i
))
3906 bitmap_set_bit (exit_block_uses
, i
);
3909 #ifdef EH_RETURN_DATA_REGNO
3910 /* Mark the registers that will contain data for the handler. */
3911 if (reload_completed
&& crtl
->calls_eh_return
)
3914 unsigned regno
= EH_RETURN_DATA_REGNO (i
);
3915 if (regno
== INVALID_REGNUM
)
3917 bitmap_set_bit (exit_block_uses
, regno
);
3921 #ifdef EH_RETURN_STACKADJ_RTX
3922 if ((!HAVE_epilogue
|| ! epilogue_completed
)
3923 && crtl
->calls_eh_return
)
3925 rtx tmp
= EH_RETURN_STACKADJ_RTX
;
3926 if (tmp
&& REG_P (tmp
))
3927 df_mark_reg (tmp
, exit_block_uses
);
3931 #ifdef EH_RETURN_HANDLER_RTX
3932 if ((!HAVE_epilogue
|| ! epilogue_completed
)
3933 && crtl
->calls_eh_return
)
3935 rtx tmp
= EH_RETURN_HANDLER_RTX
;
3936 if (tmp
&& REG_P (tmp
))
3937 df_mark_reg (tmp
, exit_block_uses
);
3941 /* Mark function return value. */
3942 diddle_return_value (df_mark_reg
, (void*) exit_block_uses
);
3946 /* Return the refs of hard registers that are used in the exit block.
3947 It uses df->exit_block_uses to determine register to include. */
3950 df_exit_block_uses_collect (struct df_collection_rec
*collection_rec
, bitmap exit_block_uses
)
3955 EXECUTE_IF_SET_IN_BITMAP (exit_block_uses
, 0, i
, bi
)
3956 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[i
], NULL
,
3957 EXIT_BLOCK_PTR
, NULL
, DF_REF_REG_USE
, 0);
3959 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3960 /* It is deliberate that this is not put in the exit block uses but
3961 I do not know why. */
3962 if (reload_completed
3963 && !bitmap_bit_p (exit_block_uses
, ARG_POINTER_REGNUM
)
3964 && bb_has_eh_pred (EXIT_BLOCK_PTR
)
3965 && fixed_regs
[ARG_POINTER_REGNUM
])
3966 df_ref_record (DF_REF_ARTIFICIAL
, collection_rec
, regno_reg_rtx
[ARG_POINTER_REGNUM
], NULL
,
3967 EXIT_BLOCK_PTR
, NULL
, DF_REF_REG_USE
, 0);
3970 df_canonize_collection_rec (collection_rec
);
3974 /* Record the set of hard registers that are used in the exit block.
3975 It uses df->exit_block_uses to determine which bit to include. */
3978 df_record_exit_block_uses (bitmap exit_block_uses
)
3980 struct df_collection_rec collection_rec
;
3981 memset (&collection_rec
, 0, sizeof (struct df_collection_rec
));
3982 collection_rec
.use_vec
= VEC_alloc (df_ref
, stack
, FIRST_PSEUDO_REGISTER
);
3984 df_exit_block_uses_collect (&collection_rec
, exit_block_uses
);
3986 /* Process bb_refs chain */
3987 df_refs_add_to_chains (&collection_rec
, BASIC_BLOCK (EXIT_BLOCK
), NULL
);
3988 VEC_free (df_ref
, stack
, collection_rec
.use_vec
);
3992 /* Update the uses in the exit block. */
3995 df_update_exit_block_uses (void)
3998 bool changed
= false;
4000 bitmap_initialize (&refs
, &df_bitmap_obstack
);
4001 df_get_exit_block_use_set (&refs
);
4002 if (df
->exit_block_uses
)
4004 if (!bitmap_equal_p (df
->exit_block_uses
, &refs
))
4006 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (EXIT_BLOCK
);
4007 df_ref_chain_delete_du_chain (bb_info
->artificial_uses
);
4008 df_ref_chain_delete (bb_info
->artificial_uses
);
4009 bb_info
->artificial_uses
= NULL
;
4015 struct df_scan_problem_data
*problem_data
4016 = (struct df_scan_problem_data
*) df_scan
->problem_data
;
4018 df
->exit_block_uses
= BITMAP_ALLOC (&problem_data
->reg_bitmaps
);
4024 df_record_exit_block_uses (&refs
);
4025 bitmap_copy (df
->exit_block_uses
,& refs
);
4026 df_set_bb_dirty (BASIC_BLOCK (EXIT_BLOCK
));
4028 bitmap_clear (&refs
);
4031 static bool initialized
= false;
4034 /* Initialize some platform specific structures. */
4037 df_hard_reg_init (void)
4039 #ifdef ELIMINABLE_REGS
4041 static const struct {const int from
, to
; } eliminables
[] = ELIMINABLE_REGS
;
4046 /* Record which registers will be eliminated. We use this in
4048 CLEAR_HARD_REG_SET (elim_reg_set
);
4050 #ifdef ELIMINABLE_REGS
4051 for (i
= 0; i
< (int) ARRAY_SIZE (eliminables
); i
++)
4052 SET_HARD_REG_BIT (elim_reg_set
, eliminables
[i
].from
);
4054 SET_HARD_REG_BIT (elim_reg_set
, FRAME_POINTER_REGNUM
);
4061 /* Recompute the parts of scanning that are based on regs_ever_live
4062 because something changed in that array. */
4065 df_update_entry_exit_and_calls (void)
4069 df_update_entry_block_defs ();
4070 df_update_exit_block_uses ();
4072 /* The call insns need to be rescanned because there may be changes
4073 in the set of registers clobbered across the call. */
4077 FOR_BB_INSNS (bb
, insn
)
4079 if (INSN_P (insn
) && CALL_P (insn
))
4080 df_insn_rescan (insn
);
4086 /* Return true if hard REG is actually used in the some instruction.
4087 There are a fair number of conditions that affect the setting of
4088 this array. See the comment in df.h for df->hard_regs_live_count
4089 for the conditions that this array is set. */
4092 df_hard_reg_used_p (unsigned int reg
)
4094 return df
->hard_regs_live_count
[reg
] != 0;
4098 /* A count of the number of times REG is actually used in the some
4099 instruction. There are a fair number of conditions that affect the
4100 setting of this array. See the comment in df.h for
4101 df->hard_regs_live_count for the conditions that this array is
4106 df_hard_reg_used_count (unsigned int reg
)
4108 return df
->hard_regs_live_count
[reg
];
4112 /* Get the value of regs_ever_live[REGNO]. */
4115 df_regs_ever_live_p (unsigned int regno
)
4117 return regs_ever_live
[regno
];
4121 /* Set regs_ever_live[REGNO] to VALUE. If this cause regs_ever_live
4122 to change, schedule that change for the next update. */
4125 df_set_regs_ever_live (unsigned int regno
, bool value
)
4127 if (regs_ever_live
[regno
] == value
)
4130 regs_ever_live
[regno
] = value
;
4132 df
->redo_entry_and_exit
= true;
4136 /* Compute "regs_ever_live" information from the underlying df
4137 information. Set the vector to all false if RESET. */
4140 df_compute_regs_ever_live (bool reset
)
4143 bool changed
= df
->redo_entry_and_exit
;
4146 memset (regs_ever_live
, 0, sizeof (regs_ever_live
));
4148 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
4149 if ((!regs_ever_live
[i
]) && df_hard_reg_used_p (i
))
4151 regs_ever_live
[i
] = true;
4155 df_update_entry_exit_and_calls ();
4156 df
->redo_entry_and_exit
= false;
4160 /*----------------------------------------------------------------------------
4161 Dataflow ref information verification functions.
4163 df_reg_chain_mark (refs, regno, is_def, is_eq_use)
4164 df_reg_chain_verify_unmarked (refs)
4165 df_refs_verify (VEC(stack,df_ref)*, ref*, bool)
4166 df_mws_verify (mw*, mw*, bool)
4167 df_insn_refs_verify (collection_rec, bb, insn, bool)
4168 df_bb_refs_verify (bb, refs, bool)
4170 df_exit_block_bitmap_verify (bool)
4171 df_entry_block_bitmap_verify (bool)
4173 ----------------------------------------------------------------------------*/
4176 /* Mark all refs in the reg chain. Verify that all of the registers
4177 are in the correct chain. */
4180 df_reg_chain_mark (df_ref refs
, unsigned int regno
,
4181 bool is_def
, bool is_eq_use
)
4183 unsigned int count
= 0;
4185 for (ref
= refs
; ref
; ref
= DF_REF_NEXT_REG (ref
))
4187 gcc_assert (!DF_REF_IS_REG_MARKED (ref
));
4189 /* If there are no def-use or use-def chains, make sure that all
4190 of the chains are clear. */
4192 gcc_assert (!DF_REF_CHAIN (ref
));
4194 /* Check to make sure the ref is in the correct chain. */
4195 gcc_assert (DF_REF_REGNO (ref
) == regno
);
4197 gcc_assert (DF_REF_REG_DEF_P (ref
));
4199 gcc_assert (!DF_REF_REG_DEF_P (ref
));
4202 gcc_assert ((DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
));
4204 gcc_assert ((DF_REF_FLAGS (ref
) & DF_REF_IN_NOTE
) == 0);
4206 if (DF_REF_NEXT_REG (ref
))
4207 gcc_assert (DF_REF_PREV_REG (DF_REF_NEXT_REG (ref
)) == ref
);
4209 DF_REF_REG_MARK (ref
);
4215 /* Verify that all of the registers in the chain are unmarked. */
4218 df_reg_chain_verify_unmarked (df_ref refs
)
4221 for (ref
= refs
; ref
; ref
= DF_REF_NEXT_REG (ref
))
4222 gcc_assert (!DF_REF_IS_REG_MARKED (ref
));
4226 /* Verify that NEW_REC and OLD_REC have exactly the same members. */
4229 df_refs_verify (VEC(df_ref
,stack
) *new_rec
, df_ref
*old_rec
,
4235 FOR_EACH_VEC_ELT (df_ref
, new_rec
, ix
, new_ref
)
4237 if (*old_rec
== NULL
|| !df_ref_equal_p (new_ref
, *old_rec
))
4245 /* Abort if fail is called from the function level verifier. If
4246 that is the context, mark this reg as being seem. */
4249 gcc_assert (DF_REF_IS_REG_MARKED (*old_rec
));
4250 DF_REF_REG_UNMARK (*old_rec
);
4257 gcc_assert (*old_rec
== NULL
);
4259 return *old_rec
== NULL
;
4264 /* Verify that NEW_REC and OLD_REC have exactly the same members. */
4267 df_mws_verify (VEC(df_mw_hardreg_ptr
,stack
) *new_rec
,
4268 struct df_mw_hardreg
**old_rec
,
4272 struct df_mw_hardreg
*new_reg
;
4274 FOR_EACH_VEC_ELT (df_mw_hardreg_ptr
, new_rec
, ix
, new_reg
)
4276 if (*old_rec
== NULL
|| !df_mw_equal_p (new_reg
, *old_rec
))
4287 gcc_assert (*old_rec
== NULL
);
4289 return *old_rec
== NULL
;
4294 /* Return true if the existing insn refs information is complete and
4295 correct. Otherwise (i.e. if there's any missing or extra refs),
4296 return the correct df_ref chain in REFS_RETURN.
4298 If ABORT_IF_FAIL, leave the refs that are verified (already in the
4299 ref chain) as DF_REF_MARKED(). If it's false, then it's a per-insn
4300 verification mode instead of the whole function, so unmark
4303 If ABORT_IF_FAIL is set, this function never returns false. */
4306 df_insn_refs_verify (struct df_collection_rec
*collection_rec
,
4311 bool ret1
, ret2
, ret3
, ret4
;
4312 unsigned int uid
= INSN_UID (insn
);
4313 struct df_insn_info
*insn_info
= DF_INSN_INFO_GET (insn
);
4315 df_insn_refs_collect (collection_rec
, bb
, insn_info
);
4317 if (!DF_INSN_UID_DEFS (uid
))
4319 /* The insn_rec was created but it was never filled out. */
4326 /* Unfortunately we cannot opt out early if one of these is not
4327 right because the marks will not get cleared. */
4328 ret1
= df_refs_verify (collection_rec
->def_vec
, DF_INSN_UID_DEFS (uid
),
4330 ret2
= df_refs_verify (collection_rec
->use_vec
, DF_INSN_UID_USES (uid
),
4332 ret3
= df_refs_verify (collection_rec
->eq_use_vec
, DF_INSN_UID_EQ_USES (uid
),
4334 ret4
= df_mws_verify (collection_rec
->mw_vec
, DF_INSN_UID_MWS (uid
),
4336 return (ret1
&& ret2
&& ret3
&& ret4
);
4340 /* Return true if all refs in the basic block are correct and complete.
4341 Due to df_ref_chain_verify, it will cause all refs
4342 that are verified to have DF_REF_MARK bit set. */
4345 df_bb_verify (basic_block bb
)
4348 struct df_scan_bb_info
*bb_info
= df_scan_get_bb_info (bb
->index
);
4349 struct df_collection_rec collection_rec
;
4351 memset (&collection_rec
, 0, sizeof (struct df_collection_rec
));
4352 collection_rec
.def_vec
= VEC_alloc (df_ref
, stack
, 128);
4353 collection_rec
.use_vec
= VEC_alloc (df_ref
, stack
, 32);
4354 collection_rec
.eq_use_vec
= VEC_alloc (df_ref
, stack
, 32);
4355 collection_rec
.mw_vec
= VEC_alloc (df_mw_hardreg_ptr
, stack
, 32);
4357 gcc_assert (bb_info
);
4359 /* Scan the block, one insn at a time, from beginning to end. */
4360 FOR_BB_INSNS_REVERSE (bb
, insn
)
4364 df_insn_refs_verify (&collection_rec
, bb
, insn
, true);
4365 df_free_collection_rec (&collection_rec
);
4368 /* Do the artificial defs and uses. */
4369 df_bb_refs_collect (&collection_rec
, bb
);
4370 df_refs_verify (collection_rec
.def_vec
, df_get_artificial_defs (bb
->index
), true);
4371 df_refs_verify (collection_rec
.use_vec
, df_get_artificial_uses (bb
->index
), true);
4372 df_free_collection_rec (&collection_rec
);
4378 /* Returns true if the entry block has correct and complete df_ref set.
4379 If not it either aborts if ABORT_IF_FAIL is true or returns false. */
4382 df_entry_block_bitmap_verify (bool abort_if_fail
)
4384 bitmap_head entry_block_defs
;
4387 bitmap_initialize (&entry_block_defs
, &df_bitmap_obstack
);
4388 df_get_entry_block_def_set (&entry_block_defs
);
4390 is_eq
= bitmap_equal_p (&entry_block_defs
, df
->entry_block_defs
);
4392 if (!is_eq
&& abort_if_fail
)
4394 print_current_pass (stderr
);
4395 fprintf (stderr
, "entry_block_defs = ");
4396 df_print_regset (stderr
, &entry_block_defs
);
4397 fprintf (stderr
, "df->entry_block_defs = ");
4398 df_print_regset (stderr
, df
->entry_block_defs
);
4402 bitmap_clear (&entry_block_defs
);
4408 /* Returns true if the exit block has correct and complete df_ref set.
4409 If not it either aborts if ABORT_IF_FAIL is true or returns false. */
4412 df_exit_block_bitmap_verify (bool abort_if_fail
)
4414 bitmap_head exit_block_uses
;
4417 bitmap_initialize (&exit_block_uses
, &df_bitmap_obstack
);
4418 df_get_exit_block_use_set (&exit_block_uses
);
4420 is_eq
= bitmap_equal_p (&exit_block_uses
, df
->exit_block_uses
);
4422 if (!is_eq
&& abort_if_fail
)
4424 print_current_pass (stderr
);
4425 fprintf (stderr
, "exit_block_uses = ");
4426 df_print_regset (stderr
, &exit_block_uses
);
4427 fprintf (stderr
, "df->exit_block_uses = ");
4428 df_print_regset (stderr
, df
->exit_block_uses
);
4432 bitmap_clear (&exit_block_uses
);
4438 /* Return true if df_ref information for all insns in all blocks are
4439 correct and complete. */
4442 df_scan_verify (void)
4446 bitmap_head regular_block_artificial_uses
;
4447 bitmap_head eh_block_artificial_uses
;
4452 /* Verification is a 4 step process. */
4454 /* (1) All of the refs are marked by going thru the reg chains. */
4455 for (i
= 0; i
< DF_REG_SIZE (df
); i
++)
4457 gcc_assert (df_reg_chain_mark (DF_REG_DEF_CHAIN (i
), i
, true, false)
4458 == DF_REG_DEF_COUNT(i
));
4459 gcc_assert (df_reg_chain_mark (DF_REG_USE_CHAIN (i
), i
, false, false)
4460 == DF_REG_USE_COUNT(i
));
4461 gcc_assert (df_reg_chain_mark (DF_REG_EQ_USE_CHAIN (i
), i
, false, true)
4462 == DF_REG_EQ_USE_COUNT(i
));
4465 /* (2) There are various bitmaps whose value may change over the
4466 course of the compilation. This step recomputes them to make
4467 sure that they have not slipped out of date. */
4468 bitmap_initialize (®ular_block_artificial_uses
, &df_bitmap_obstack
);
4469 bitmap_initialize (&eh_block_artificial_uses
, &df_bitmap_obstack
);
4471 df_get_regular_block_artificial_uses (®ular_block_artificial_uses
);
4472 df_get_eh_block_artificial_uses (&eh_block_artificial_uses
);
4474 bitmap_ior_into (&eh_block_artificial_uses
,
4475 ®ular_block_artificial_uses
);
4477 /* Check artificial_uses bitmaps didn't change. */
4478 gcc_assert (bitmap_equal_p (®ular_block_artificial_uses
,
4479 &df
->regular_block_artificial_uses
));
4480 gcc_assert (bitmap_equal_p (&eh_block_artificial_uses
,
4481 &df
->eh_block_artificial_uses
));
4483 bitmap_clear (®ular_block_artificial_uses
);
4484 bitmap_clear (&eh_block_artificial_uses
);
4486 /* Verify entry block and exit block. These only verify the bitmaps,
4487 the refs are verified in df_bb_verify. */
4488 df_entry_block_bitmap_verify (true);
4489 df_exit_block_bitmap_verify (true);
4491 /* (3) All of the insns in all of the blocks are traversed and the
4492 marks are cleared both in the artificial refs attached to the
4493 blocks and the real refs inside the insns. It is a failure to
4494 clear a mark that has not been set as this means that the ref in
4495 the block or insn was not in the reg chain. */
4500 /* (4) See if all reg chains are traversed a second time. This time
4501 a check is made that the marks are clear. A set mark would be a
4502 from a reg that is not in any insn or basic block. */
4504 for (i
= 0; i
< DF_REG_SIZE (df
); i
++)
4506 df_reg_chain_verify_unmarked (DF_REG_DEF_CHAIN (i
));
4507 df_reg_chain_verify_unmarked (DF_REG_USE_CHAIN (i
));
4508 df_reg_chain_verify_unmarked (DF_REG_EQ_USE_CHAIN (i
));