comparison gcc/df.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Form lists of pseudo register references for autoinc optimization 1 /* Form lists of pseudo register references for autoinc optimization
2 for GNU compiler. This is part of flow optimization. 2 for GNU compiler. This is part of flow optimization.
3 Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 3 Copyright (C) 1999-2017 Free Software Foundation, Inc.
4 2009, 2010 Free Software Foundation, Inc.
5 Originally contributed by Michael P. Hayes 4 Originally contributed by Michael P. Hayes
6 (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com) 5 (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
7 Major rewrite contributed by Danny Berlin (dberlin@dberlin.org) 6 Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
8 and Kenneth Zadeck (zadeck@naturalbridge.com). 7 and Kenneth Zadeck (zadeck@naturalbridge.com).
9 8
24 <http://www.gnu.org/licenses/>. */ 23 <http://www.gnu.org/licenses/>. */
25 24
26 #ifndef GCC_DF_H 25 #ifndef GCC_DF_H
27 #define GCC_DF_H 26 #define GCC_DF_H
28 27
29 #include "bitmap.h"
30 #include "regset.h" 28 #include "regset.h"
31 #include "sbitmap.h"
32 #include "basic-block.h"
33 #include "alloc-pool.h" 29 #include "alloc-pool.h"
34 #include "timevar.h" 30 #include "timevar.h"
35 31
36 struct dataflow; 32 struct dataflow;
37 struct df_d; 33 struct df_d;
45 /* Scanning is not really a dataflow problem, but it is useful to have 41 /* Scanning is not really a dataflow problem, but it is useful to have
46 the basic block functions in the vector so that things get done in 42 the basic block functions in the vector so that things get done in
47 a uniform manner. The last four problems can be added or deleted 43 a uniform manner. The last four problems can be added or deleted
48 at any time are always defined (though LIVE is always there at -O2 44 at any time are always defined (though LIVE is always there at -O2
49 or higher); the others are always there. */ 45 or higher); the others are always there. */
50 #define DF_SCAN 0 46 enum df_problem_id
51 #define DF_LR 1 /* Live Registers backward. */ 47 {
52 #define DF_LIVE 2 /* Live Registers & Uninitialized Registers */ 48 DF_SCAN,
53 #define DF_RD 3 /* Reaching Defs. */ 49 DF_LR, /* Live Registers backward. */
54 #define DF_CHAIN 4 /* Def-Use and/or Use-Def Chains. */ 50 DF_LIVE, /* Live Registers & Uninitialized Registers */
55 #define DF_WORD_LR 5 /* Subreg tracking lr. */ 51 DF_RD, /* Reaching Defs. */
56 #define DF_NOTE 6 /* REG_DEF and REG_UNUSED notes. */ 52 DF_CHAIN, /* Def-Use and/or Use-Def Chains. */
57 #define DF_MD 7 /* Multiple Definitions. */ 53 DF_WORD_LR, /* Subreg tracking lr. */
58 54 DF_NOTE, /* REG_DEAD and REG_UNUSED notes. */
59 #define DF_LAST_PROBLEM_PLUS1 (DF_MD + 1) 55 DF_MD, /* Multiple Definitions. */
56 DF_MIR, /* Must-initialized Registers. */
57
58 DF_LAST_PROBLEM_PLUS1
59 };
60 60
61 /* Dataflow direction. */ 61 /* Dataflow direction. */
62 enum df_flow_dir 62 enum df_flow_dir
63 { 63 {
64 DF_NONE, 64 DF_NONE,
175 /* For uses, the refs within eq notes may be added for 175 /* For uses, the refs within eq notes may be added for
176 DF_REF_ORDER_BY_REG. */ 176 DF_REF_ORDER_BY_REG. */
177 DF_REF_ORDER_BY_REG_WITH_NOTES, 177 DF_REF_ORDER_BY_REG_WITH_NOTES,
178 178
179 /* Organize the refs in insn order. The insns are ordered within a 179 /* Organize the refs in insn order. The insns are ordered within a
180 block, and the blocks are ordered by FOR_ALL_BB. */ 180 block, and the blocks are ordered by FOR_ALL_BB_FN. */
181 DF_REF_ORDER_BY_INSN, 181 DF_REF_ORDER_BY_INSN,
182 182
183 /* For uses, the refs within eq notes may be added for 183 /* For uses, the refs within eq notes may be added for
184 DF_REF_ORDER_BY_INSN. */ 184 DF_REF_ORDER_BY_INSN. */
185 DF_REF_ORDER_BY_INSN_WITH_NOTES 185 DF_REF_ORDER_BY_INSN_WITH_NOTES
237 typedef void (*df_dump_problem_function) (FILE *); 237 typedef void (*df_dump_problem_function) (FILE *);
238 238
239 /* Function to dump top or bottom of basic block results to FILE. */ 239 /* Function to dump top or bottom of basic block results to FILE. */
240 typedef void (*df_dump_bb_problem_function) (basic_block, FILE *); 240 typedef void (*df_dump_bb_problem_function) (basic_block, FILE *);
241 241
242 /* Function to dump before or after an insn to FILE. */
243 typedef void (*df_dump_insn_problem_function) (const rtx_insn *, FILE *);
244
242 /* Function to dump top or bottom of basic block results to FILE. */ 245 /* Function to dump top or bottom of basic block results to FILE. */
243 typedef void (*df_verify_solution_start) (void); 246 typedef void (*df_verify_solution_start) (void);
244 247
245 /* Function to dump top or bottom of basic block results to FILE. */ 248 /* Function to dump top or bottom of basic block results to FILE. */
246 typedef void (*df_verify_solution_end) (void); 249 typedef void (*df_verify_solution_end) (void);
249 typedefs for doc for the function fields. */ 252 typedefs for doc for the function fields. */
250 253
251 struct df_problem { 254 struct df_problem {
252 /* The unique id of the problem. This is used it index into 255 /* The unique id of the problem. This is used it index into
253 df->defined_problems to make accessing the problem data easy. */ 256 df->defined_problems to make accessing the problem data easy. */
254 unsigned int id; 257 enum df_problem_id id;
255 enum df_flow_dir dir; /* Dataflow direction. */ 258 enum df_flow_dir dir; /* Dataflow direction. */
256 df_alloc_function alloc_fun; 259 df_alloc_function alloc_fun;
257 df_reset_function reset_fun; 260 df_reset_function reset_fun;
258 df_free_bb_function free_bb_fun; 261 df_free_bb_function free_bb_fun;
259 df_local_compute_function local_compute_fun; 262 df_local_compute_function local_compute_fun;
266 df_free_function free_fun; 269 df_free_function free_fun;
267 df_remove_problem_function remove_problem_fun; 270 df_remove_problem_function remove_problem_fun;
268 df_dump_problem_function dump_start_fun; 271 df_dump_problem_function dump_start_fun;
269 df_dump_bb_problem_function dump_top_fun; 272 df_dump_bb_problem_function dump_top_fun;
270 df_dump_bb_problem_function dump_bottom_fun; 273 df_dump_bb_problem_function dump_bottom_fun;
274 df_dump_insn_problem_function dump_insn_top_fun;
275 df_dump_insn_problem_function dump_insn_bottom_fun;
271 df_verify_solution_start verify_start_fun; 276 df_verify_solution_start verify_start_fun;
272 df_verify_solution_end verify_end_fun; 277 df_verify_solution_end verify_end_fun;
273 struct df_problem *dependent_problem; 278 const struct df_problem *dependent_problem;
274 unsigned int block_info_elt_size; 279 unsigned int block_info_elt_size;
275 280
276 /* The timevar id associated with this pass. */ 281 /* The timevar id associated with this pass. */
277 timevar_id_t tv_id; 282 timevar_id_t tv_id;
278 283
283 288
284 289
285 /* The specific instance of the problem to solve. */ 290 /* The specific instance of the problem to solve. */
286 struct dataflow 291 struct dataflow
287 { 292 {
288 struct df_problem *problem; /* The problem to be solved. */ 293 const struct df_problem *problem; /* The problem to be solved. */
289 294
290 /* Array indexed by bb->index, that contains basic block problem and 295 /* Array indexed by bb->index, that contains basic block problem and
291 solution specific information. */ 296 solution specific information. */
292 void *block_info; 297 void *block_info;
293 unsigned int block_info_size; 298 unsigned int block_info_size;
294 299
295 /* The pool to allocate the block_info from. */ 300 /* The pool to allocate the block_info from. */
296 alloc_pool block_pool; 301 object_allocator<df_link> *block_pool;
297 302
298 /* The lr and live problems have their transfer functions recomputed 303 /* The lr and live problems have their transfer functions recomputed
299 only if necessary. This is possible for them because, the 304 only if necessary. This is possible for them because, the
300 problems are kept active for the entire backend and their 305 problems are kept active for the entire backend and their
301 transfer functions are indexed by the REGNO. These are not 306 transfer functions are indexed by the REGNO. These are not
333 instruction. These are factored into individual uses and defs but 338 instruction. These are factored into individual uses and defs but
334 the aggregate is still needed to service the REG_DEAD and 339 the aggregate is still needed to service the REG_DEAD and
335 REG_UNUSED notes. */ 340 REG_UNUSED notes. */
336 struct df_mw_hardreg 341 struct df_mw_hardreg
337 { 342 {
343 df_mw_hardreg *next; /* Next entry for this instruction. */
338 rtx mw_reg; /* The multiword hardreg. */ 344 rtx mw_reg; /* The multiword hardreg. */
339 /* These two bitfields are intentionally oversized, in the hope that 345 /* These two bitfields are intentionally oversized, in the hope that
340 accesses to 16-bit fields will usually be quicker. */ 346 accesses to 16-bit fields will usually be quicker. */
341 ENUM_BITFIELD(df_ref_type) type : 16; 347 ENUM_BITFIELD(df_ref_type) type : 16;
342 /* Used to see if the ref is read or write. */ 348 /* Used to see if the ref is read or write. */
359 ENUM_BITFIELD(df_ref_type) type : 8; 365 ENUM_BITFIELD(df_ref_type) type : 8;
360 /* Type of ref. */ 366 /* Type of ref. */
361 int flags : 16; /* Various df_ref_flags. */ 367 int flags : 16; /* Various df_ref_flags. */
362 unsigned int regno; /* The register number referenced. */ 368 unsigned int regno; /* The register number referenced. */
363 rtx reg; /* The register referenced. */ 369 rtx reg; /* The register referenced. */
370 union df_ref_d *next_loc; /* Next ref for same insn or bb. */
364 struct df_link *chain; /* Head of def-use, use-def. */ 371 struct df_link *chain; /* Head of def-use, use-def. */
365 /* Pointer to the insn info of the containing instruction. FIXME! 372 /* Pointer to the insn info of the containing instruction. FIXME!
366 Currently this is NULL for artificial refs but this will be used 373 Currently this is NULL for artificial refs but this will be used
367 when FUDs are added. */ 374 when FUDs are added. */
368 struct df_insn_info *insn_info; 375 struct df_insn_info *insn_info;
369 /* For each regno, there are three chains of refs, one for the uses, 376 /* For each regno, there are three chains of refs, one for the uses,
370 the eq_uses and the defs. These chains go thru the refs 377 the eq_uses and the defs. These chains go through the refs
371 themselves rather than using an external structure. */ 378 themselves rather than using an external structure. */
372 union df_ref_d *next_reg; /* Next ref with same regno and type. */ 379 union df_ref_d *next_reg; /* Next ref with same regno and type. */
373 union df_ref_d *prev_reg; /* Prev ref with same regno and type. */ 380 union df_ref_d *prev_reg; /* Prev ref with same regno and type. */
374 /* Location in the ref table. This is only valid after a call to 381 /* Location in the ref table. This is only valid after a call to
375 df_maybe_reorganize_[use,def]_refs which is an expensive operation. */ 382 df_maybe_reorganize_[use,def]_refs which is an expensive operation. */
413 420
414 421
415 /* One of these structures is allocated for every insn. */ 422 /* One of these structures is allocated for every insn. */
416 struct df_insn_info 423 struct df_insn_info
417 { 424 {
418 rtx insn; /* The insn this info comes from. */ 425 rtx_insn *insn; /* The insn this info comes from. */
419 df_ref *defs; /* Head of insn-def chain. */ 426 df_ref defs; /* Head of insn-def chain. */
420 df_ref *uses; /* Head of insn-use chain. */ 427 df_ref uses; /* Head of insn-use chain. */
421 /* Head of insn-use chain for uses in REG_EQUAL/EQUIV notes. */ 428 /* Head of insn-use chain for uses in REG_EQUAL/EQUIV notes. */
422 df_ref *eq_uses; 429 df_ref eq_uses;
423 struct df_mw_hardreg **mw_hardregs; 430 struct df_mw_hardreg *mw_hardregs;
424 /* The logical uid of the insn in the basic block. This is valid 431 /* The logical uid of the insn in the basic block. This is valid
425 after any call to df_analyze but may rot after insns are added, 432 after any call to df_analyze but may rot after insns are added,
426 deleted or moved. */ 433 deleted or moved. */
427 int luid; 434 int luid;
428 }; 435 };
441 /* Flags that control the building of chains. */ 448 /* Flags that control the building of chains. */
442 DF_DU_CHAIN = 1, /* Build DU chains. */ 449 DF_DU_CHAIN = 1, /* Build DU chains. */
443 DF_UD_CHAIN = 2 /* Build UD chains. */ 450 DF_UD_CHAIN = 2 /* Build UD chains. */
444 }; 451 };
445 452
453 enum df_scan_flags
454 {
455 /* Flags for the SCAN problem. */
456 DF_SCAN_EMPTY_ENTRY_EXIT = 1 /* Don't define any registers in the entry
457 block; don't use any in the exit block. */
458 };
459
446 enum df_changeable_flags 460 enum df_changeable_flags
447 { 461 {
448 /* Scanning flags. */ 462 /* Scanning flags. */
449 /* Flag to control the running of dce as a side effect of building LR. */ 463 /* Flag to control the running of dce as a side effect of building LR. */
450 DF_LR_RUN_DCE = 1 << 0, /* Run DCE. */ 464 DF_LR_RUN_DCE = 1 << 0, /* Run DCE. */
461 /* Cause df_insn_rescan df_notes_rescan and df_insn_delete, to 475 /* Cause df_insn_rescan df_notes_rescan and df_insn_delete, to
462 return after marking the insn for later processing. This allows all 476 return after marking the insn for later processing. This allows all
463 rescans to be batched. */ 477 rescans to be batched. */
464 DF_DEFER_INSN_RESCAN = 1 << 5, 478 DF_DEFER_INSN_RESCAN = 1 << 5,
465 479
466 DF_VERIFY_SCHEDULED = 1 << 6 480 /* Compute the reaching defs problem as "live and reaching defs" (LR&RD).
481 A DEF is reaching and live at insn I if DEF reaches I and REGNO(DEF)
482 is in LR_IN of the basic block containing I. */
483 DF_RD_PRUNE_DEAD_DEFS = 1 << 6,
484
485 DF_VERIFY_SCHEDULED = 1 << 7
467 }; 486 };
468 487
469 /* Two of these structures are inline in df, one for the uses and one 488 /* Two of these structures are inline in df, one for the uses and one
470 for the defs. This structure is only contains the refs within the 489 for the defs. This structure is only contains the refs within the
471 boundary of the df_set_blocks if that has been defined. */ 490 boundary of the df_set_blocks if that has been defined. */
561 bitmap_head insns_to_delete; 580 bitmap_head insns_to_delete;
562 bitmap_head insns_to_rescan; 581 bitmap_head insns_to_rescan;
563 bitmap_head insns_to_notes_rescan; 582 bitmap_head insns_to_notes_rescan;
564 int *postorder; /* The current set of basic blocks 583 int *postorder; /* The current set of basic blocks
565 in reverse postorder. */ 584 in reverse postorder. */
566 int *postorder_inverted; /* The current set of basic blocks 585 vec<int> postorder_inverted; /* The current set of basic blocks
567 in reverse postorder of inverted CFG. */ 586 in reverse postorder of inverted CFG. */
568 int n_blocks; /* The number of blocks in reverse postorder. */ 587 int n_blocks; /* The number of blocks in reverse postorder. */
569 int n_blocks_inverted; /* The number of blocks
570 in reverse postorder of inverted CFG. */
571 588
572 /* An array [FIRST_PSEUDO_REGISTER], indexed by regno, of the number 589 /* An array [FIRST_PSEUDO_REGISTER], indexed by regno, of the number
573 of refs that qualify as being real hard regs uses. Artificial 590 of refs that qualify as being real hard regs uses. Artificial
574 uses and defs as well as refs in eq notes are ignored. If the 591 uses and defs as well as refs in eq notes are ignored. If the
575 ref is a def, it cannot be a MAY_CLOBBER def. If the ref is a 592 ref is a def, it cannot be a MAY_CLOBBER def. If the ref is a
576 use, it cannot be the emim_reg_set or be the frame or arg pointer 593 use, it cannot be the emim_reg_set or be the frame or arg pointer
577 register. 594 register. Uses in debug insns are ignored.
578 595
579 IT IS NOT ACCEPTABLE TO MANUALLY CHANGE THIS ARRAY. This array 596 IT IS NOT ACCEPTABLE TO MANUALLY CHANGE THIS ARRAY. This array
580 always reflects the actual number of refs in the insn stream that 597 always reflects the actual number of refs in the insn stream that
581 satisfy the above criteria. */ 598 satisfy the above criteria. */
582 unsigned int *hard_regs_live_count; 599 unsigned int *hard_regs_live_count;
596 /* True if someone added or deleted something from regs_ever_live so 613 /* True if someone added or deleted something from regs_ever_live so
597 that the entry and exit blocks need be reprocessed. */ 614 that the entry and exit blocks need be reprocessed. */
598 bool redo_entry_and_exit; 615 bool redo_entry_and_exit;
599 }; 616 };
600 617
601 #define DF_SCAN_BB_INFO(BB) (df_scan_get_bb_info((BB)->index)) 618 #define DF_SCAN_BB_INFO(BB) (df_scan_get_bb_info ((BB)->index))
602 #define DF_RD_BB_INFO(BB) (df_rd_get_bb_info((BB)->index)) 619 #define DF_RD_BB_INFO(BB) (df_rd_get_bb_info ((BB)->index))
603 #define DF_LR_BB_INFO(BB) (df_lr_get_bb_info((BB)->index)) 620 #define DF_LR_BB_INFO(BB) (df_lr_get_bb_info ((BB)->index))
604 #define DF_LIVE_BB_INFO(BB) (df_live_get_bb_info((BB)->index)) 621 #define DF_LIVE_BB_INFO(BB) (df_live_get_bb_info ((BB)->index))
605 #define DF_WORD_LR_BB_INFO(BB) (df_word_lr_get_bb_info((BB)->index)) 622 #define DF_WORD_LR_BB_INFO(BB) (df_word_lr_get_bb_info ((BB)->index))
606 #define DF_MD_BB_INFO(BB) (df_md_get_bb_info((BB)->index)) 623 #define DF_MD_BB_INFO(BB) (df_md_get_bb_info ((BB)->index))
624 #define DF_MIR_BB_INFO(BB) (df_mir_get_bb_info ((BB)->index))
607 625
608 /* Most transformations that wish to use live register analysis will 626 /* Most transformations that wish to use live register analysis will
609 use these macros. This info is the and of the lr and live sets. */ 627 use these macros. This info is the and of the lr and live sets. */
610 #define DF_LIVE_IN(BB) (&DF_LIVE_BB_INFO(BB)->in) 628 #define DF_LIVE_IN(BB) (&DF_LIVE_BB_INFO (BB)->in)
611 #define DF_LIVE_OUT(BB) (&DF_LIVE_BB_INFO(BB)->out) 629 #define DF_LIVE_OUT(BB) (&DF_LIVE_BB_INFO (BB)->out)
630
631 #define DF_MIR_IN(BB) (&DF_MIR_BB_INFO (BB)->in)
632 #define DF_MIR_OUT(BB) (&DF_MIR_BB_INFO (BB)->out)
612 633
613 /* These macros are used by passes that are not tolerant of 634 /* These macros are used by passes that are not tolerant of
614 uninitialized variables. This intolerance should eventually 635 uninitialized variables. This intolerance should eventually
615 be fixed. */ 636 be fixed. */
616 #define DF_LR_IN(BB) (&DF_LR_BB_INFO(BB)->in) 637 #define DF_LR_IN(BB) (&DF_LR_BB_INFO (BB)->in)
617 #define DF_LR_OUT(BB) (&DF_LR_BB_INFO(BB)->out) 638 #define DF_LR_OUT(BB) (&DF_LR_BB_INFO (BB)->out)
618 639
619 /* These macros are used by passes that are not tolerant of 640 /* These macros are used by passes that are not tolerant of
620 uninitialized variables. This intolerance should eventually 641 uninitialized variables. This intolerance should eventually
621 be fixed. */ 642 be fixed. */
622 #define DF_WORD_LR_IN(BB) (&DF_WORD_LR_BB_INFO(BB)->in) 643 #define DF_WORD_LR_IN(BB) (&DF_WORD_LR_BB_INFO (BB)->in)
623 #define DF_WORD_LR_OUT(BB) (&DF_WORD_LR_BB_INFO(BB)->out) 644 #define DF_WORD_LR_OUT(BB) (&DF_WORD_LR_BB_INFO (BB)->out)
624 645
625 /* Macros to access the elements within the ref structure. */ 646 /* Macros to access the elements within the ref structure. */
626 647
627 648
628 #define DF_REF_REAL_REG(REF) (GET_CODE ((REF)->base.reg) == SUBREG \ 649 #define DF_REF_REAL_REG(REF) (GET_CODE ((REF)->base.reg) == SUBREG \
629 ? SUBREG_REG ((REF)->base.reg) : ((REF)->base.reg)) 650 ? SUBREG_REG ((REF)->base.reg) : ((REF)->base.reg))
630 #define DF_REF_REGNO(REF) ((REF)->base.regno) 651 #define DF_REF_REGNO(REF) ((REF)->base.regno)
631 #define DF_REF_REAL_LOC(REF) (GET_CODE (*((REF)->regular_ref.loc)) == SUBREG \ 652 #define DF_REF_REAL_LOC(REF) (GET_CODE (*((REF)->regular_ref.loc)) == SUBREG \
632 ? &SUBREG_REG (*((REF)->regular_ref.loc)) : ((REF)->regular_ref.loc)) 653 ? &SUBREG_REG (*((REF)->regular_ref.loc)) : ((REF)->regular_ref.loc))
633 #define DF_REF_REG(REF) ((REF)->base.reg) 654 #define DF_REF_REG(REF) ((REF)->base.reg)
634 #define DF_REF_LOC(REF) (DF_REF_CLASS(REF) == DF_REF_REGULAR ? \ 655 #define DF_REF_LOC(REF) (DF_REF_CLASS (REF) == DF_REF_REGULAR ? \
635 (REF)->regular_ref.loc : NULL) 656 (REF)->regular_ref.loc : NULL)
636 #define DF_REF_BB(REF) (DF_REF_IS_ARTIFICIAL(REF) ? \ 657 #define DF_REF_BB(REF) (DF_REF_IS_ARTIFICIAL (REF) \
637 (REF)->artificial_ref.bb : BLOCK_FOR_INSN (DF_REF_INSN(REF))) 658 ? (REF)->artificial_ref.bb \
659 : BLOCK_FOR_INSN (DF_REF_INSN (REF)))
638 #define DF_REF_BBNO(REF) (DF_REF_BB (REF)->index) 660 #define DF_REF_BBNO(REF) (DF_REF_BB (REF)->index)
639 #define DF_REF_INSN_INFO(REF) ((REF)->base.insn_info) 661 #define DF_REF_INSN_INFO(REF) ((REF)->base.insn_info)
640 #define DF_REF_INSN(REF) ((REF)->base.insn_info->insn) 662 #define DF_REF_INSN(REF) ((REF)->base.insn_info->insn)
641 #define DF_REF_INSN_UID(REF) (INSN_UID (DF_REF_INSN(REF))) 663 #define DF_REF_INSN_UID(REF) (INSN_UID (DF_REF_INSN(REF)))
642 #define DF_REF_CLASS(REF) ((REF)->base.cl) 664 #define DF_REF_CLASS(REF) ((REF)->base.cl)
649 #define DF_REF_FLAGS_CLEAR(REF, v) (DF_REF_FLAGS (REF) &= ~(v)) 671 #define DF_REF_FLAGS_CLEAR(REF, v) (DF_REF_FLAGS (REF) &= ~(v))
650 #define DF_REF_ORDER(REF) ((REF)->base.ref_order) 672 #define DF_REF_ORDER(REF) ((REF)->base.ref_order)
651 /* If DF_REF_IS_ARTIFICIAL () is true, this is not a real 673 /* If DF_REF_IS_ARTIFICIAL () is true, this is not a real
652 definition/use, but an artificial one created to model always live 674 definition/use, but an artificial one created to model always live
653 registers, eh uses, etc. */ 675 registers, eh uses, etc. */
654 #define DF_REF_IS_ARTIFICIAL(REF) (DF_REF_CLASS(REF) == DF_REF_ARTIFICIAL) 676 #define DF_REF_IS_ARTIFICIAL(REF) (DF_REF_CLASS (REF) == DF_REF_ARTIFICIAL)
655 #define DF_REF_REG_MARK(REF) (DF_REF_FLAGS_SET ((REF),DF_REF_REG_MARKER)) 677 #define DF_REF_REG_MARK(REF) (DF_REF_FLAGS_SET ((REF),DF_REF_REG_MARKER))
656 #define DF_REF_REG_UNMARK(REF) (DF_REF_FLAGS_CLEAR ((REF),DF_REF_REG_MARKER)) 678 #define DF_REF_REG_UNMARK(REF) (DF_REF_FLAGS_CLEAR ((REF),DF_REF_REG_MARKER))
657 #define DF_REF_IS_REG_MARKED(REF) (DF_REF_FLAGS_IS_SET ((REF),DF_REF_REG_MARKER)) 679 #define DF_REF_IS_REG_MARKED(REF) (DF_REF_FLAGS_IS_SET ((REF),DF_REF_REG_MARKER))
680 #define DF_REF_NEXT_LOC(REF) ((REF)->base.next_loc)
658 #define DF_REF_NEXT_REG(REF) ((REF)->base.next_reg) 681 #define DF_REF_NEXT_REG(REF) ((REF)->base.next_reg)
659 #define DF_REF_PREV_REG(REF) ((REF)->base.prev_reg) 682 #define DF_REF_PREV_REG(REF) ((REF)->base.prev_reg)
660 /* The following two macros may only be applied if one of 683 /* The following two macros may only be applied if one of
661 DF_REF_SIGN_EXTRACT | DF_REF_ZERO_EXTRACT is true. */ 684 DF_REF_SIGN_EXTRACT | DF_REF_ZERO_EXTRACT is true. */
662 #define DF_REF_EXTRACT_WIDTH(REF) ((REF)->extract_ref.width) 685 #define DF_REF_EXTRACT_WIDTH(REF) ((REF)->extract_ref.width)
663 #define DF_REF_EXTRACT_OFFSET(REF) ((REF)->extract_ref.offset) 686 #define DF_REF_EXTRACT_OFFSET(REF) ((REF)->extract_ref.offset)
664 #define DF_REF_EXTRACT_MODE(REF) ((REF)->extract_ref.mode) 687 #define DF_REF_EXTRACT_MODE(REF) ((REF)->extract_ref.mode)
665 688
666 /* Macros to determine the reference type. */ 689 /* Macros to determine the reference type. */
667 #define DF_REF_REG_DEF_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_DEF) 690 #define DF_REF_REG_DEF_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_DEF)
668 #define DF_REF_REG_USE_P(REF) ((REF) && !DF_REF_REG_DEF_P (REF)) 691 #define DF_REF_REG_USE_P(REF) (!DF_REF_REG_DEF_P (REF))
669 #define DF_REF_REG_MEM_STORE_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_STORE) 692 #define DF_REF_REG_MEM_STORE_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_STORE)
670 #define DF_REF_REG_MEM_LOAD_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_LOAD) 693 #define DF_REF_REG_MEM_LOAD_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_LOAD)
671 #define DF_REF_REG_MEM_P(REF) (DF_REF_REG_MEM_STORE_P (REF) \ 694 #define DF_REF_REG_MEM_P(REF) (DF_REF_REG_MEM_STORE_P (REF) \
672 || DF_REF_REG_MEM_LOAD_P (REF)) 695 || DF_REF_REG_MEM_LOAD_P (REF))
673 696
674 #define DF_MWS_REG_DEF_P(MREF) (DF_MWS_TYPE (MREF) == DF_REF_REG_DEF) 697 #define DF_MWS_REG_DEF_P(MREF) (DF_MWS_TYPE (MREF) == DF_REF_REG_DEF)
675 #define DF_MWS_REG_USE_P(MREF) ((MREF) && !DF_MWS_REG_DEF_P (MREF)) 698 #define DF_MWS_REG_USE_P(MREF) (!DF_MWS_REG_DEF_P (MREF))
699 #define DF_MWS_NEXT(MREF) ((MREF)->next)
676 #define DF_MWS_TYPE(MREF) ((MREF)->type) 700 #define DF_MWS_TYPE(MREF) ((MREF)->type)
677 701
678 /* Macros to get the refs out of def_info or use_info refs table. If 702 /* Macros to get the refs out of def_info or use_info refs table. If
679 the focus of the dataflow has been set to some subset of blocks 703 the focus of the dataflow has been set to some subset of blocks
680 with df_set_blocks, these macros will only find the uses and defs 704 with df_set_blocks, these macros will only find the uses and defs
711 #define DF_REG_EQ_USE_COUNT(REG) (df->eq_use_regs[(REG)]->n_refs) 735 #define DF_REG_EQ_USE_COUNT(REG) (df->eq_use_regs[(REG)]->n_refs)
712 736
713 /* Macros to access the elements within the reg_info structure table. */ 737 /* Macros to access the elements within the reg_info structure table. */
714 738
715 #define DF_REGNO_FIRST_DEF(REGNUM) \ 739 #define DF_REGNO_FIRST_DEF(REGNUM) \
716 (DF_REG_DEF_GET(REGNUM) ? DF_REG_DEF_GET(REGNUM) : 0) 740 (DF_REG_DEF_GET(REGNUM) ? DF_REG_DEF_GET (REGNUM) : 0)
717 #define DF_REGNO_LAST_USE(REGNUM) \ 741 #define DF_REGNO_LAST_USE(REGNUM) \
718 (DF_REG_USE_GET(REGNUM) ? DF_REG_USE_GET(REGNUM) : 0) 742 (DF_REG_USE_GET(REGNUM) ? DF_REG_USE_GET (REGNUM) : 0)
719 743
720 /* Macros to access the elements within the insn_info structure table. */ 744 /* Macros to access the elements within the insn_info structure table. */
721 745
722 #define DF_INSN_SIZE() ((df)->insns_size) 746 #define DF_INSN_SIZE() ((df)->insns_size)
723 #define DF_INSN_INFO_GET(INSN) (df->insns[(INSN_UID(INSN))]) 747 #define DF_INSN_INFO_GET(INSN) (df->insns[(INSN_UID (INSN))])
724 #define DF_INSN_INFO_SET(INSN,VAL) (df->insns[(INSN_UID (INSN))]=(VAL)) 748 #define DF_INSN_INFO_SET(INSN,VAL) (df->insns[(INSN_UID (INSN))]=(VAL))
725 #define DF_INSN_INFO_LUID(II) ((II)->luid) 749 #define DF_INSN_INFO_LUID(II) ((II)->luid)
726 #define DF_INSN_INFO_DEFS(II) ((II)->defs) 750 #define DF_INSN_INFO_DEFS(II) ((II)->defs)
727 #define DF_INSN_INFO_USES(II) ((II)->uses) 751 #define DF_INSN_INFO_USES(II) ((II)->uses)
728 #define DF_INSN_INFO_EQ_USES(II) ((II)->eq_uses) 752 #define DF_INSN_INFO_EQ_USES(II) ((II)->eq_uses)
729 753 #define DF_INSN_INFO_MWS(II) ((II)->mw_hardregs)
730 #define DF_INSN_LUID(INSN) (DF_INSN_INFO_LUID (DF_INSN_INFO_GET(INSN))) 754
731 #define DF_INSN_DEFS(INSN) (DF_INSN_INFO_DEFS (DF_INSN_INFO_GET(INSN))) 755 #define DF_INSN_LUID(INSN) (DF_INSN_INFO_LUID (DF_INSN_INFO_GET (INSN)))
732 #define DF_INSN_USES(INSN) (DF_INSN_INFO_USES (DF_INSN_INFO_GET(INSN))) 756 #define DF_INSN_DEFS(INSN) (DF_INSN_INFO_DEFS (DF_INSN_INFO_GET (INSN)))
733 #define DF_INSN_EQ_USES(INSN) (DF_INSN_INFO_EQ_USES (DF_INSN_INFO_GET(INSN))) 757 #define DF_INSN_USES(INSN) (DF_INSN_INFO_USES (DF_INSN_INFO_GET (INSN)))
758 #define DF_INSN_EQ_USES(INSN) (DF_INSN_INFO_EQ_USES (DF_INSN_INFO_GET (INSN)))
734 759
735 #define DF_INSN_UID_GET(UID) (df->insns[(UID)]) 760 #define DF_INSN_UID_GET(UID) (df->insns[(UID)])
736 #define DF_INSN_UID_SET(UID,VAL) (df->insns[(UID)]=(VAL)) 761 #define DF_INSN_UID_SET(UID,VAL) (df->insns[(UID)]=(VAL))
737 #define DF_INSN_UID_SAFE_GET(UID) (((unsigned)(UID) < DF_INSN_SIZE()) \ 762 #define DF_INSN_UID_SAFE_GET(UID) (((unsigned)(UID) < DF_INSN_SIZE ()) \
738 ? DF_INSN_UID_GET (UID) \ 763 ? DF_INSN_UID_GET (UID) \
739 : NULL) 764 : NULL)
740 #define DF_INSN_UID_LUID(INSN) (DF_INSN_UID_GET(INSN)->luid) 765 #define DF_INSN_UID_LUID(INSN) (DF_INSN_UID_GET (INSN)->luid)
741 #define DF_INSN_UID_DEFS(INSN) (DF_INSN_UID_GET(INSN)->defs) 766 #define DF_INSN_UID_DEFS(INSN) (DF_INSN_UID_GET (INSN)->defs)
742 #define DF_INSN_UID_USES(INSN) (DF_INSN_UID_GET(INSN)->uses) 767 #define DF_INSN_UID_USES(INSN) (DF_INSN_UID_GET (INSN)->uses)
743 #define DF_INSN_UID_EQ_USES(INSN) (DF_INSN_UID_GET(INSN)->eq_uses) 768 #define DF_INSN_UID_EQ_USES(INSN) (DF_INSN_UID_GET (INSN)->eq_uses)
744 #define DF_INSN_UID_MWS(INSN) (DF_INSN_UID_GET(INSN)->mw_hardregs) 769 #define DF_INSN_UID_MWS(INSN) (DF_INSN_UID_GET (INSN)->mw_hardregs)
770
771 #define FOR_EACH_INSN_INFO_DEF(ITER, INSN) \
772 for (ITER = DF_INSN_INFO_DEFS (INSN); ITER; ITER = DF_REF_NEXT_LOC (ITER))
773
774 #define FOR_EACH_INSN_INFO_USE(ITER, INSN) \
775 for (ITER = DF_INSN_INFO_USES (INSN); ITER; ITER = DF_REF_NEXT_LOC (ITER))
776
777 #define FOR_EACH_INSN_INFO_EQ_USE(ITER, INSN) \
778 for (ITER = DF_INSN_INFO_EQ_USES (INSN); ITER; ITER = DF_REF_NEXT_LOC (ITER))
779
780 #define FOR_EACH_INSN_INFO_MW(ITER, INSN) \
781 for (ITER = DF_INSN_INFO_MWS (INSN); ITER; ITER = DF_MWS_NEXT (ITER))
782
783 #define FOR_EACH_INSN_DEF(ITER, INSN) \
784 FOR_EACH_INSN_INFO_DEF(ITER, DF_INSN_INFO_GET (INSN))
785
786 #define FOR_EACH_INSN_USE(ITER, INSN) \
787 FOR_EACH_INSN_INFO_USE(ITER, DF_INSN_INFO_GET (INSN))
788
789 #define FOR_EACH_INSN_EQ_USE(ITER, INSN) \
790 FOR_EACH_INSN_INFO_EQ_USE(ITER, DF_INSN_INFO_GET (INSN))
791
792 #define FOR_EACH_ARTIFICIAL_USE(ITER, BB_INDEX) \
793 for (ITER = df_get_artificial_uses (BB_INDEX); ITER; \
794 ITER = DF_REF_NEXT_LOC (ITER))
795
796 #define FOR_EACH_ARTIFICIAL_DEF(ITER, BB_INDEX) \
797 for (ITER = df_get_artificial_defs (BB_INDEX); ITER; \
798 ITER = DF_REF_NEXT_LOC (ITER))
745 799
746 /* An obstack for bitmap not related to specific dataflow problems. 800 /* An obstack for bitmap not related to specific dataflow problems.
747 This obstack should e.g. be used for bitmaps with a short life time 801 This obstack should e.g. be used for bitmaps with a short life time
748 such as temporary bitmaps. This obstack is declared in df-core.c. */ 802 such as temporary bitmaps. This obstack is declared in df-core.c. */
749 803
760 artificial defs. These are logically located at the top of the 814 artificial defs. These are logically located at the top of the
761 block. 815 block.
762 816
763 Blocks that are the targets of non-local goto's have the hard 817 Blocks that are the targets of non-local goto's have the hard
764 frame pointer defined at the top of the block. */ 818 frame pointer defined at the top of the block. */
765 df_ref *artificial_defs; 819 df_ref artificial_defs;
766 820
767 /* Blocks that are targets of exception edges may have some 821 /* Blocks that are targets of exception edges may have some
768 artificial uses. These are logically at the top of the block. 822 artificial uses. These are logically at the top of the block.
769 823
770 Most blocks have artificial uses at the bottom of the block. */ 824 Most blocks have artificial uses at the bottom of the block. */
771 df_ref *artificial_uses; 825 df_ref artificial_uses;
772 }; 826 };
773 827
774 828
775 /* Reaching definitions. All bitmaps are indexed by the id field of 829 /* Reaching definitions. All bitmaps are indexed by the id field of
776 the ref except sparse_kill which is indexed by regno. */ 830 the ref except sparse_kill which is indexed by regno. For the
831 LR&RD problem, the kill set is not complete: It does not contain
832 DEFs killed because the set register has died in the LR set. */
777 struct df_rd_bb_info 833 struct df_rd_bb_info
778 { 834 {
779 /* Local sets to describe the basic blocks. */ 835 /* Local sets to describe the basic blocks. */
780 bitmap_head kill; 836 bitmap_head kill;
781 bitmap_head sparse_kill; 837 bitmap_head sparse_kill;
848 - except artificial defs at the top. */ 904 - except artificial defs at the top. */
849 bitmap_head use; /* The set of registers used in this block. */ 905 bitmap_head use; /* The set of registers used in this block. */
850 906
851 /* The results of the dataflow problem. */ 907 /* The results of the dataflow problem. */
852 bitmap_head in; /* Just before the block itself. */ 908 bitmap_head in; /* Just before the block itself. */
909 bitmap_head out; /* At the bottom of the block. */
910 };
911
912 /* Must-initialized registers. All bitmaps are referenced by the
913 register number. */
914 struct df_mir_bb_info
915 {
916 /* Local sets to describe the basic blocks. */
917 bitmap_head kill; /* The set of registers unset in this block. Calls,
918 for instance, unset registers. */
919 bitmap_head gen; /* The set of registers set in this block, excluding the
920 ones killed later on in this block. */
921
922 /* The results of the dataflow problem. */
923 bitmap_head in; /* At the top of the block. */
853 bitmap_head out; /* At the bottom of the block. */ 924 bitmap_head out; /* At the bottom of the block. */
854 }; 925 };
855 926
856 927
857 /* This is used for debugging and for the dumpers to find the latest 928 /* This is used for debugging and for the dumpers to find the latest
864 #define df_live (df->problems_by_index[DF_LIVE]) 935 #define df_live (df->problems_by_index[DF_LIVE])
865 #define df_chain (df->problems_by_index[DF_CHAIN]) 936 #define df_chain (df->problems_by_index[DF_CHAIN])
866 #define df_word_lr (df->problems_by_index[DF_WORD_LR]) 937 #define df_word_lr (df->problems_by_index[DF_WORD_LR])
867 #define df_note (df->problems_by_index[DF_NOTE]) 938 #define df_note (df->problems_by_index[DF_NOTE])
868 #define df_md (df->problems_by_index[DF_MD]) 939 #define df_md (df->problems_by_index[DF_MD])
940 #define df_mir (df->problems_by_index[DF_MIR])
869 941
870 /* This symbol turns on checking that each modification of the cfg has 942 /* This symbol turns on checking that each modification of the cfg has
871 been identified to the appropriate df routines. It is not part of 943 been identified to the appropriate df routines. It is not part of
872 verification per se because the check that the final solution has 944 verification per se because the check that the final solution has
873 not changed covers this. However, if the solution is not being 945 not changed covers this. However, if the solution is not being
879 #endif 951 #endif
880 952
881 953
882 /* Functions defined in df-core.c. */ 954 /* Functions defined in df-core.c. */
883 955
884 extern void df_add_problem (struct df_problem *); 956 extern void df_add_problem (const struct df_problem *);
885 extern int df_set_flags (int); 957 extern int df_set_flags (int);
886 extern int df_clear_flags (int); 958 extern int df_clear_flags (int);
887 extern void df_set_blocks (bitmap); 959 extern void df_set_blocks (bitmap);
888 extern void df_remove_problem (struct dataflow *); 960 extern void df_remove_problem (struct dataflow *);
889 extern void df_finish_pass (bool); 961 extern void df_finish_pass (bool);
890 extern void df_analyze_problem (struct dataflow *, bitmap, int *, int); 962 extern void df_analyze_problem (struct dataflow *, bitmap, int *, int);
891 extern void df_analyze (void); 963 extern void df_analyze ();
964 extern void df_analyze_loop (struct loop *);
892 extern int df_get_n_blocks (enum df_flow_dir); 965 extern int df_get_n_blocks (enum df_flow_dir);
893 extern int *df_get_postorder (enum df_flow_dir); 966 extern int *df_get_postorder (enum df_flow_dir);
894 extern void df_simple_dataflow (enum df_flow_dir, df_init_function, 967 extern void df_simple_dataflow (enum df_flow_dir, df_init_function,
895 df_confluence_function_0, df_confluence_function_n, 968 df_confluence_function_0, df_confluence_function_n,
896 df_transfer_function, bitmap, int *, int); 969 df_transfer_function, bitmap, int *, int);
904 #ifdef DF_DEBUG_CFG 977 #ifdef DF_DEBUG_CFG
905 extern void df_check_cfg_clean (void); 978 extern void df_check_cfg_clean (void);
906 #endif 979 #endif
907 extern df_ref df_bb_regno_first_def_find (basic_block, unsigned int); 980 extern df_ref df_bb_regno_first_def_find (basic_block, unsigned int);
908 extern df_ref df_bb_regno_last_def_find (basic_block, unsigned int); 981 extern df_ref df_bb_regno_last_def_find (basic_block, unsigned int);
909 extern df_ref df_find_def (rtx, rtx); 982 extern df_ref df_find_def (rtx_insn *, rtx);
910 extern bool df_reg_defined (rtx, rtx); 983 extern bool df_reg_defined (rtx_insn *, rtx);
911 extern df_ref df_find_use (rtx, rtx); 984 extern df_ref df_find_use (rtx_insn *, rtx);
912 extern bool df_reg_used (rtx, rtx); 985 extern bool df_reg_used (rtx_insn *, rtx);
913 extern void df_worklist_dataflow (struct dataflow *,bitmap, int *, int); 986 extern void df_worklist_dataflow (struct dataflow *,bitmap, int *, int);
914 extern void df_print_regset (FILE *file, bitmap r); 987 extern void df_print_regset (FILE *file, bitmap r);
915 extern void df_print_word_regset (FILE *file, bitmap r); 988 extern void df_print_word_regset (FILE *file, bitmap r);
916 extern void df_dump (FILE *); 989 extern void df_dump (FILE *);
917 extern void df_dump_region (FILE *); 990 extern void df_dump_region (FILE *);
918 extern void df_dump_start (FILE *); 991 extern void df_dump_start (FILE *);
919 extern void df_dump_top (basic_block, FILE *); 992 extern void df_dump_top (basic_block, FILE *);
920 extern void df_dump_bottom (basic_block, FILE *); 993 extern void df_dump_bottom (basic_block, FILE *);
921 extern void df_refs_chain_dump (df_ref *, bool, FILE *); 994 extern void df_dump_insn_top (const rtx_insn *, FILE *);
995 extern void df_dump_insn_bottom (const rtx_insn *, FILE *);
996 extern void df_refs_chain_dump (df_ref, bool, FILE *);
922 extern void df_regs_chain_dump (df_ref, FILE *); 997 extern void df_regs_chain_dump (df_ref, FILE *);
923 extern void df_insn_debug (rtx, bool, FILE *); 998 extern void df_insn_debug (rtx_insn *, bool, FILE *);
924 extern void df_insn_debug_regno (rtx, FILE *); 999 extern void df_insn_debug_regno (rtx_insn *, FILE *);
925 extern void df_regno_debug (unsigned int, FILE *); 1000 extern void df_regno_debug (unsigned int, FILE *);
926 extern void df_ref_debug (df_ref, FILE *); 1001 extern void df_ref_debug (df_ref, FILE *);
927 extern void debug_df_insn (rtx); 1002 extern void debug_df_insn (rtx_insn *);
928 extern void debug_df_regno (unsigned int); 1003 extern void debug_df_regno (unsigned int);
929 extern void debug_df_reg (rtx); 1004 extern void debug_df_reg (rtx);
930 extern void debug_df_defno (unsigned int); 1005 extern void debug_df_defno (unsigned int);
931 extern void debug_df_useno (unsigned int); 1006 extern void debug_df_useno (unsigned int);
932 extern void debug_df_ref (df_ref); 1007 extern void debug_df_ref (df_ref);
935 /* Functions defined in df-problems.c. */ 1010 /* Functions defined in df-problems.c. */
936 1011
937 extern struct df_link *df_chain_create (df_ref, df_ref); 1012 extern struct df_link *df_chain_create (df_ref, df_ref);
938 extern void df_chain_unlink (df_ref); 1013 extern void df_chain_unlink (df_ref);
939 extern void df_chain_copy (df_ref, struct df_link *); 1014 extern void df_chain_copy (df_ref, struct df_link *);
940 extern bitmap df_get_live_in (basic_block);
941 extern bitmap df_get_live_out (basic_block);
942 extern void df_grow_bb_info (struct dataflow *); 1015 extern void df_grow_bb_info (struct dataflow *);
943 extern void df_chain_dump (struct df_link *, FILE *); 1016 extern void df_chain_dump (struct df_link *, FILE *);
944 extern void df_print_bb_index (basic_block bb, FILE *file); 1017 extern void df_print_bb_index (basic_block bb, FILE *file);
945 extern void df_rd_add_problem (void); 1018 extern void df_rd_add_problem (void);
946 extern void df_rd_simulate_artificial_defs_at_top (basic_block, bitmap); 1019 extern void df_rd_simulate_artificial_defs_at_top (basic_block, bitmap);
947 extern void df_rd_simulate_one_insn (basic_block, rtx, bitmap); 1020 extern void df_rd_simulate_one_insn (basic_block, rtx_insn *, bitmap);
948 extern void df_lr_add_problem (void); 1021 extern void df_lr_add_problem (void);
949 extern void df_lr_verify_transfer_functions (void); 1022 extern void df_lr_verify_transfer_functions (void);
950 extern void df_live_verify_transfer_functions (void); 1023 extern void df_live_verify_transfer_functions (void);
951 extern void df_live_add_problem (void); 1024 extern void df_live_add_problem (void);
952 extern void df_live_set_all_dirty (void); 1025 extern void df_live_set_all_dirty (void);
953 extern void df_chain_add_problem (unsigned int); 1026 extern void df_chain_add_problem (unsigned int);
954 extern void df_word_lr_add_problem (void); 1027 extern void df_word_lr_add_problem (void);
955 extern bool df_word_lr_mark_ref (df_ref, bool, bitmap); 1028 extern bool df_word_lr_mark_ref (df_ref, bool, bitmap);
956 extern bool df_word_lr_simulate_defs (rtx, bitmap); 1029 extern bool df_word_lr_simulate_defs (rtx_insn *, bitmap);
957 extern void df_word_lr_simulate_uses (rtx, bitmap); 1030 extern void df_word_lr_simulate_uses (rtx_insn *, bitmap);
958 extern void df_word_lr_simulate_artificial_refs_at_top (basic_block, bitmap); 1031 extern void df_word_lr_simulate_artificial_refs_at_top (basic_block, bitmap);
959 extern void df_word_lr_simulate_artificial_refs_at_end (basic_block, bitmap); 1032 extern void df_word_lr_simulate_artificial_refs_at_end (basic_block, bitmap);
960 extern void df_note_add_problem (void); 1033 extern void df_note_add_problem (void);
961 extern void df_md_add_problem (void); 1034 extern void df_md_add_problem (void);
962 extern void df_md_simulate_artificial_defs_at_top (basic_block, bitmap); 1035 extern void df_md_simulate_artificial_defs_at_top (basic_block, bitmap);
963 extern void df_md_simulate_one_insn (basic_block, rtx, bitmap); 1036 extern void df_md_simulate_one_insn (basic_block, rtx_insn *, bitmap);
964 extern void df_simulate_find_noclobber_defs (rtx, bitmap); 1037 extern void df_mir_add_problem (void);
965 extern void df_simulate_find_defs (rtx, bitmap); 1038 extern void df_mir_simulate_one_insn (basic_block, rtx_insn *, bitmap, bitmap);
966 extern void df_simulate_defs (rtx, bitmap); 1039 extern void df_simulate_find_noclobber_defs (rtx_insn *, bitmap);
967 extern void df_simulate_uses (rtx, bitmap); 1040 extern void df_simulate_find_defs (rtx_insn *, bitmap);
1041 extern void df_simulate_defs (rtx_insn *, bitmap);
1042 extern void df_simulate_uses (rtx_insn *, bitmap);
968 extern void df_simulate_initialize_backwards (basic_block, bitmap); 1043 extern void df_simulate_initialize_backwards (basic_block, bitmap);
969 extern void df_simulate_one_insn_backwards (basic_block, rtx, bitmap); 1044 extern void df_simulate_one_insn_backwards (basic_block, rtx_insn *, bitmap);
970 extern void df_simulate_finalize_backwards (basic_block, bitmap); 1045 extern void df_simulate_finalize_backwards (basic_block, bitmap);
971 extern void df_simulate_initialize_forwards (basic_block, bitmap); 1046 extern void df_simulate_initialize_forwards (basic_block, bitmap);
972 extern void df_simulate_one_insn_forwards (basic_block, rtx, bitmap); 1047 extern void df_simulate_one_insn_forwards (basic_block, rtx_insn *, bitmap);
973 extern void simulate_backwards_to_point (basic_block, regset, rtx); 1048 extern void simulate_backwards_to_point (basic_block, regset, rtx);
974 extern bool can_move_insns_across (rtx, rtx, rtx, rtx, basic_block, regset, 1049 extern bool can_move_insns_across (rtx_insn *, rtx_insn *,
975 regset, rtx *); 1050 rtx_insn *, rtx_insn *,
1051 basic_block, regset,
1052 regset, rtx_insn **);
976 /* Functions defined in df-scan.c. */ 1053 /* Functions defined in df-scan.c. */
977 1054
978 extern void df_scan_alloc (bitmap); 1055 extern void df_scan_alloc (bitmap);
979 extern void df_scan_add_problem (void); 1056 extern void df_scan_add_problem (void);
980 extern void df_grow_reg_info (void); 1057 extern void df_grow_reg_info (void);
981 extern void df_grow_insn_info (void); 1058 extern void df_grow_insn_info (void);
982 extern void df_scan_blocks (void); 1059 extern void df_scan_blocks (void);
983 extern df_ref df_ref_create (rtx, rtx *, rtx,basic_block, 1060 extern void df_uses_create (rtx *, rtx_insn *, int);
984 enum df_ref_type, int ref_flags); 1061 extern struct df_insn_info * df_insn_create_insn_record (rtx_insn *);
985 extern void df_uses_create (rtx *, rtx, int); 1062 extern void df_insn_delete (rtx_insn *);
986 extern void df_ref_remove (df_ref);
987 extern struct df_insn_info * df_insn_create_insn_record (rtx);
988 extern void df_insn_delete (basic_block, unsigned int);
989 extern void df_bb_refs_record (int, bool); 1063 extern void df_bb_refs_record (int, bool);
990 extern bool df_insn_rescan (rtx); 1064 extern bool df_insn_rescan (rtx_insn *);
991 extern bool df_insn_rescan_debug_internal (rtx); 1065 extern bool df_insn_rescan_debug_internal (rtx_insn *);
992 extern void df_insn_rescan_all (void); 1066 extern void df_insn_rescan_all (void);
993 extern void df_process_deferred_rescans (void); 1067 extern void df_process_deferred_rescans (void);
994 extern void df_recompute_luids (basic_block); 1068 extern void df_recompute_luids (basic_block);
995 extern void df_insn_change_bb (rtx, basic_block); 1069 extern void df_insn_change_bb (rtx_insn *, basic_block);
996 extern void df_maybe_reorganize_use_refs (enum df_ref_order); 1070 extern void df_maybe_reorganize_use_refs (enum df_ref_order);
997 extern void df_maybe_reorganize_def_refs (enum df_ref_order); 1071 extern void df_maybe_reorganize_def_refs (enum df_ref_order);
998 extern void df_ref_change_reg_with_loc (int, int, rtx); 1072 extern void df_ref_change_reg_with_loc (rtx, unsigned int);
999 extern void df_notes_rescan (rtx); 1073 extern void df_notes_rescan (rtx_insn *);
1000 extern void df_hard_reg_init (void); 1074 extern void df_hard_reg_init (void);
1001 extern void df_update_entry_block_defs (void); 1075 extern void df_update_entry_block_defs (void);
1002 extern void df_update_exit_block_uses (void); 1076 extern void df_update_exit_block_uses (void);
1003 extern void df_update_entry_exit_and_calls (void); 1077 extern void df_update_entry_exit_and_calls (void);
1004 extern bool df_hard_reg_used_p (unsigned int); 1078 extern bool df_hard_reg_used_p (unsigned int);
1005 extern unsigned int df_hard_reg_used_count (unsigned int); 1079 extern unsigned int df_hard_reg_used_count (unsigned int);
1006 extern bool df_regs_ever_live_p (unsigned int); 1080 extern bool df_regs_ever_live_p (unsigned int);
1007 extern void df_set_regs_ever_live (unsigned int, bool); 1081 extern void df_set_regs_ever_live (unsigned int, bool);
1008 extern void df_compute_regs_ever_live (bool); 1082 extern void df_compute_regs_ever_live (bool);
1009 extern bool df_read_modify_subreg_p (rtx);
1010 extern void df_scan_verify (void); 1083 extern void df_scan_verify (void);
1011 1084
1012 /* Get basic block info. */ 1085
1086 /*----------------------------------------------------------------------------
1087 Public functions access functions for the dataflow problems.
1088 ----------------------------------------------------------------------------*/
1013 1089
1014 static inline struct df_scan_bb_info * 1090 static inline struct df_scan_bb_info *
1015 df_scan_get_bb_info (unsigned int index) 1091 df_scan_get_bb_info (unsigned int index)
1016 { 1092 {
1017 if (index < df_scan->block_info_size) 1093 if (index < df_scan->block_info_size)
1063 return &((struct df_word_lr_bb_info *) df_word_lr->block_info)[index]; 1139 return &((struct df_word_lr_bb_info *) df_word_lr->block_info)[index];
1064 else 1140 else
1065 return NULL; 1141 return NULL;
1066 } 1142 }
1067 1143
1144 static inline struct df_mir_bb_info *
1145 df_mir_get_bb_info (unsigned int index)
1146 {
1147 if (index < df_mir->block_info_size)
1148 return &((struct df_mir_bb_info *) df_mir->block_info)[index];
1149 else
1150 return NULL;
1151 }
1152
1153 /* Get the live at out set for BB no matter what problem happens to be
1154 defined. This function is used by the register allocators who
1155 choose different dataflow problems depending on the optimization
1156 level. */
1157
1158 static inline bitmap
1159 df_get_live_out (basic_block bb)
1160 {
1161 gcc_checking_assert (df_lr);
1162
1163 if (df_live)
1164 return DF_LIVE_OUT (bb);
1165 else
1166 return DF_LR_OUT (bb);
1167 }
1168
1169 /* Get the live at in set for BB no matter what problem happens to be
1170 defined. This function is used by the register allocators who
1171 choose different dataflow problems depending on the optimization
1172 level. */
1173
1174 static inline bitmap
1175 df_get_live_in (basic_block bb)
1176 {
1177 gcc_checking_assert (df_lr);
1178
1179 if (df_live)
1180 return DF_LIVE_IN (bb);
1181 else
1182 return DF_LR_IN (bb);
1183 }
1184
1185 /* Get basic block info. */
1068 /* Get the artificial defs for a basic block. */ 1186 /* Get the artificial defs for a basic block. */
1069 1187
1070 static inline df_ref * 1188 static inline df_ref
1071 df_get_artificial_defs (unsigned int bb_index) 1189 df_get_artificial_defs (unsigned int bb_index)
1072 { 1190 {
1073 return df_scan_get_bb_info (bb_index)->artificial_defs; 1191 return df_scan_get_bb_info (bb_index)->artificial_defs;
1074 } 1192 }
1075 1193
1076 1194
1077 /* Get the artificial uses for a basic block. */ 1195 /* Get the artificial uses for a basic block. */
1078 1196
1079 static inline df_ref * 1197 static inline df_ref
1080 df_get_artificial_uses (unsigned int bb_index) 1198 df_get_artificial_uses (unsigned int bb_index)
1081 { 1199 {
1082 return df_scan_get_bb_info (bb_index)->artificial_uses; 1200 return df_scan_get_bb_info (bb_index)->artificial_uses;
1083 } 1201 }
1084 1202
1203 /* If INSN defines exactly one register, return the associated reference,
1204 otherwise return null. */
1205
1206 static inline df_ref
1207 df_single_def (const df_insn_info *info)
1208 {
1209 df_ref defs = DF_INSN_INFO_DEFS (info);
1210 return defs && !DF_REF_NEXT_LOC (defs) ? defs : NULL;
1211 }
1212
1213 /* If INSN uses exactly one register, return the associated reference,
1214 otherwise return null. */
1215
1216 static inline df_ref
1217 df_single_use (const df_insn_info *info)
1218 {
1219 df_ref uses = DF_INSN_INFO_USES (info);
1220 return uses && !DF_REF_NEXT_LOC (uses) ? uses : NULL;
1221 }
1085 1222
1086 /* web */ 1223 /* web */
1087 1224
1088 /* This entry is allocated for each reference in the insn stream. */ 1225 class web_entry_base
1089 struct web_entry 1226 {
1090 { 1227 private:
1091 /* Pointer to the parent in the union/find tree. */ 1228 /* Reference to the parent in the union/find tree. */
1092 struct web_entry *pred; 1229 web_entry_base *pred_pvt;
1093 /* Newly assigned register to the entry. Set only for roots. */ 1230
1094 rtx reg; 1231 public:
1095 void* extra_info; 1232 /* Accessors. */
1096 }; 1233 web_entry_base *pred () { return pred_pvt; }
1097 1234 void set_pred (web_entry_base *p) { pred_pvt = p; }
1098 extern struct web_entry *unionfind_root (struct web_entry *); 1235
1099 extern bool unionfind_union (struct web_entry *, struct web_entry *); 1236 /* Find representative in union-find tree. */
1100 extern void union_defs (df_ref, struct web_entry *, 1237 web_entry_base *unionfind_root ();
1101 unsigned int *used, struct web_entry *, 1238
1102 bool (*fun) (struct web_entry *, struct web_entry *)); 1239 /* Union with another set, returning TRUE if they are already unioned. */
1240 friend bool unionfind_union (web_entry_base *first, web_entry_base *second);
1241 };
1103 1242
1104 #endif /* GCC_DF_H */ 1243 #endif /* GCC_DF_H */