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