cfg.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Control flow graph manipulation code header file.
  2. Copyright (C) 2014-2018 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_CFG_H
  16. #define GCC_CFG_H
  17. #include "dominance.h"
  18. /* What sort of profiling information we have. */
  19. enum profile_status_d
  20. {
  21. PROFILE_ABSENT,
  22. PROFILE_GUESSED,
  23. PROFILE_READ,
  24. PROFILE_LAST /* Last value, used by profile streaming. */
  25. };
  26. /* A structure to group all the per-function control flow graph data.
  27. The x_* prefixing is necessary because otherwise references to the
  28. fields of this struct are interpreted as the defines for backward
  29. source compatibility following the definition of this struct. */
  30. struct GTY(()) control_flow_graph {
  31. /* Block pointers for the exit and entry of a function.
  32. These are always the head and tail of the basic block list. */
  33. basic_block x_entry_block_ptr;
  34. basic_block x_exit_block_ptr;
  35. /* Index by basic block number, get basic block struct info. */
  36. vec<basic_block, va_gc> *x_basic_block_info;
  37. /* Number of basic blocks in this flow graph. */
  38. int x_n_basic_blocks;
  39. /* Number of edges in this flow graph. */
  40. int x_n_edges;
  41. /* The first free basic block number. */
  42. int x_last_basic_block;
  43. /* UIDs for LABEL_DECLs. */
  44. int last_label_uid;
  45. /* Mapping of labels to their associated blocks. At present
  46. only used for the gimple CFG. */
  47. vec<basic_block, va_gc> *x_label_to_block_map;
  48. enum profile_status_d x_profile_status;
  49. /* Whether the dominators and the postdominators are available. */
  50. enum dom_state x_dom_computed[2];
  51. /* Number of basic blocks in the dominance tree. */
  52. unsigned x_n_bbs_in_dom_tree[2];
  53. /* Maximal number of entities in the single jumptable. Used to estimate
  54. final flowgraph size. */
  55. int max_jumptable_ents;
  56. /* Maximal count of BB in function. */
  57. profile_count count_max;
  58. };
  59. extern void init_flow (function *);
  60. extern void clear_edges (function *);
  61. extern basic_block alloc_block (void);
  62. extern void link_block (basic_block, basic_block);
  63. extern void unlink_block (basic_block);
  64. extern void compact_blocks (void);
  65. extern void expunge_block (basic_block);
  66. extern edge unchecked_make_edge (basic_block, basic_block, int);
  67. extern edge cached_make_edge (sbitmap, basic_block, basic_block, int);
  68. extern edge make_edge (basic_block, basic_block, int);
  69. extern edge make_single_succ_edge (basic_block, basic_block, int);
  70. extern void remove_edge_raw (edge);
  71. extern void redirect_edge_succ (edge, basic_block);
  72. extern void redirect_edge_pred (edge, basic_block);
  73. extern void clear_bb_flags (void);
  74. extern void dump_edge_info (FILE *, edge, dump_flags_t, int);
  75. extern void debug (edge_def &ref);
  76. extern void debug (edge_def *ptr);
  77. extern void alloc_aux_for_blocks (int);
  78. extern void clear_aux_for_blocks (void);
  79. extern void free_aux_for_blocks (void);
  80. extern void alloc_aux_for_edge (edge, int);
  81. extern void alloc_aux_for_edges (int);
  82. extern void clear_aux_for_edges (void);
  83. extern void free_aux_for_edges (void);
  84. extern void debug_bb (basic_block);
  85. extern basic_block debug_bb_n (int);
  86. extern void dump_bb_info (FILE *, basic_block, int, dump_flags_t, bool, bool);
  87. extern void brief_dump_cfg (FILE *, dump_flags_t);
  88. extern void update_bb_profile_for_threading (basic_block, profile_count, edge);
  89. extern void scale_bbs_frequencies_profile_count (basic_block *, int,
  90. profile_count, profile_count);
  91. extern void scale_bbs_frequencies (basic_block *, int, profile_probability);
  92. extern void initialize_original_copy_tables (void);
  93. extern void reset_original_copy_tables (void);
  94. extern void free_original_copy_tables (void);
  95. extern bool original_copy_tables_initialized_p (void);
  96. extern void set_bb_original (basic_block, basic_block);
  97. extern basic_block get_bb_original (basic_block);
  98. extern void set_bb_copy (basic_block, basic_block);
  99. extern basic_block get_bb_copy (basic_block);
  100. void set_loop_copy (struct loop *, struct loop *);
  101. struct loop *get_loop_copy (struct loop *);
  102. #endif /* GCC_CFG_H */