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