cfg.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* Control flow graph manipulation code header file.
  2. Copyright (C) 2014-2015 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. /* What sort of profiling information we have. */
  18. enum profile_status_d
  19. {
  20. PROFILE_ABSENT,
  21. PROFILE_GUESSED,
  22. PROFILE_READ,
  23. PROFILE_LAST /* Last value, used by profile streaming. */
  24. };
  25. /* A structure to group all the per-function control flow graph data.
  26. The x_* prefixing is necessary because otherwise references to the
  27. fields of this struct are interpreted as the defines for backward
  28. source compatibility following the definition of this struct. */
  29. struct GTY(()) control_flow_graph {
  30. /* Block pointers for the exit and entry of a function.
  31. These are always the head and tail of the basic block list. */
  32. basic_block x_entry_block_ptr;
  33. basic_block x_exit_block_ptr;
  34. /* Index by basic block number, get basic block struct info. */
  35. vec<basic_block, va_gc> *x_basic_block_info;
  36. /* Number of basic blocks in this flow graph. */
  37. int x_n_basic_blocks;
  38. /* Number of edges in this flow graph. */
  39. int x_n_edges;
  40. /* The first free basic block number. */
  41. int x_last_basic_block;
  42. /* UIDs for LABEL_DECLs. */
  43. int last_label_uid;
  44. /* Mapping of labels to their associated blocks. At present
  45. only used for the gimple CFG. */
  46. vec<basic_block, va_gc> *x_label_to_block_map;
  47. enum profile_status_d x_profile_status;
  48. /* Whether the dominators and the postdominators are available. */
  49. enum dom_state x_dom_computed[2];
  50. /* Number of basic blocks in the dominance tree. */
  51. unsigned x_n_bbs_in_dom_tree[2];
  52. /* Maximal number of entities in the single jumptable. Used to estimate
  53. final flowgraph size. */
  54. int max_jumptable_ents;
  55. };
  56. extern void init_flow (struct function *);
  57. extern void clear_edges (void);
  58. extern basic_block alloc_block (void);
  59. extern void link_block (basic_block, basic_block);
  60. extern void unlink_block (basic_block);
  61. extern void compact_blocks (void);
  62. extern void expunge_block (basic_block);
  63. extern edge unchecked_make_edge (basic_block, basic_block, int);
  64. extern edge cached_make_edge (sbitmap, basic_block, basic_block, int);
  65. extern edge make_edge (basic_block, basic_block, int);
  66. extern edge make_single_succ_edge (basic_block, basic_block, int);
  67. extern void remove_edge_raw (edge);
  68. extern void redirect_edge_succ (edge, basic_block);
  69. extern void redirect_edge_pred (edge, basic_block);
  70. extern void clear_bb_flags (void);
  71. extern void dump_edge_info (FILE *, edge, int, int);
  72. extern void debug (edge_def &ref);
  73. extern void debug (edge_def *ptr);
  74. extern void alloc_aux_for_blocks (int);
  75. extern void clear_aux_for_blocks (void);
  76. extern void free_aux_for_blocks (void);
  77. extern void alloc_aux_for_edge (edge, int);
  78. extern void alloc_aux_for_edges (int);
  79. extern void clear_aux_for_edges (void);
  80. extern void free_aux_for_edges (void);
  81. extern void debug_bb (basic_block);
  82. extern basic_block debug_bb_n (int);
  83. extern void dump_bb_info (FILE *, basic_block, int, int, bool, bool);
  84. extern void brief_dump_cfg (FILE *, int);
  85. extern void update_bb_profile_for_threading (basic_block, int, gcov_type, edge);
  86. extern void scale_bbs_frequencies_int (basic_block *, int, int, int);
  87. extern void scale_bbs_frequencies_gcov_type (basic_block *, int, gcov_type,
  88. gcov_type);
  89. extern void initialize_original_copy_tables (void);
  90. extern void free_original_copy_tables (void);
  91. extern void set_bb_original (basic_block, basic_block);
  92. extern basic_block get_bb_original (basic_block);
  93. extern void set_bb_copy (basic_block, basic_block);
  94. extern basic_block get_bb_copy (basic_block);
  95. void set_loop_copy (struct loop *, struct loop *);
  96. struct loop *get_loop_copy (struct loop *);
  97. #endif /* GCC_CFG_H */