]>
Commit | Line | Data |
---|---|---|
9ee634e3 | 1 | /* Hooks for cfg representation specific functions. |
66647d44 JJ |
2 | Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 |
3 | Free Software Foundation, Inc. | |
9ee634e3 JH |
4 | Contributed by Sebastian Pop <s.pop@laposte.net> |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
9dcd6f09 | 10 | the Free Software Foundation; either version 3, or (at your option) |
9ee634e3 JH |
11 | any later version. |
12 | ||
13 | GCC is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
9ee634e3 | 21 | |
78bde837 | 22 | /* Only basic-block.h includes this. */ |
9ee634e3 JH |
23 | |
24 | struct cfg_hooks | |
25 | { | |
f470c378 ZD |
26 | /* Name of the corresponding ir. */ |
27 | const char *name; | |
28 | ||
29 | /* Debugging. */ | |
30 | int (*verify_flow_info) (void); | |
a315c44c | 31 | void (*dump_bb) (FILE *, basic_block, int, int); |
9ee634e3 JH |
32 | |
33 | /* Basic CFG manipulation. */ | |
34 | ||
6614fd40 | 35 | /* Return new basic block. */ |
f55ade6e | 36 | basic_block (*create_basic_block) (void *head, void *end, basic_block after); |
bc35512f | 37 | |
9ee634e3 | 38 | /* Redirect edge E to the given basic block B and update underlying program |
6de9cd9a DN |
39 | representation. Returns edge representing redirected branch (that may not |
40 | be equivalent to E in the case of duplicate edges being removed) or NULL | |
41 | if edge is not easily redirectable for whatever reason. */ | |
42 | edge (*redirect_edge_and_branch) (edge e, basic_block b); | |
9ee634e3 JH |
43 | |
44 | /* Same as the above but allows redirecting of fallthru edges. In that case | |
0e61db61 NS |
45 | newly created forwarder basic block is returned. The edge must |
46 | not be abnormal. */ | |
d329e058 | 47 | basic_block (*redirect_edge_and_branch_force) (edge, basic_block); |
9ee634e3 | 48 | |
14fa2cc0 ZD |
49 | /* Returns true if it is possible to remove the edge by redirecting it |
50 | to the destination of the other edge going from its source. */ | |
9678086d | 51 | bool (*can_remove_branch_p) (const_edge); |
14fa2cc0 | 52 | |
f470c378 ZD |
53 | /* Remove statements corresponding to a given basic block. */ |
54 | void (*delete_basic_block) (basic_block); | |
55 | ||
56 | /* Creates a new basic block just after basic block B by splitting | |
57 | everything after specified instruction I. */ | |
58 | basic_block (*split_block) (basic_block b, void * i); | |
b8698a0f | 59 | |
f470c378 ZD |
60 | /* Move block B immediately after block A. */ |
61 | bool (*move_block_after) (basic_block b, basic_block a); | |
9ee634e3 | 62 | |
bc35512f | 63 | /* Return true when blocks A and B can be merged into single basic block. */ |
b48d0358 | 64 | bool (*can_merge_blocks_p) (basic_block a, basic_block b); |
bc35512f JH |
65 | |
66 | /* Merge blocks A and B. */ | |
f55ade6e | 67 | void (*merge_blocks) (basic_block a, basic_block b); |
bc35512f | 68 | |
6de9cd9a DN |
69 | /* Predict edge E using PREDICTOR to given PROBABILITY. */ |
70 | void (*predict_edge) (edge e, enum br_predictor predictor, int probability); | |
71 | ||
72 | /* Return true if the one of outgoing edges is already predicted by | |
73 | PREDICTOR. */ | |
9678086d | 74 | bool (*predicted_by_p) (const_basic_block bb, enum br_predictor predictor); |
6de9cd9a DN |
75 | |
76 | /* Return true when block A can be duplicated. */ | |
9678086d | 77 | bool (*can_duplicate_block_p) (const_basic_block a); |
6de9cd9a DN |
78 | |
79 | /* Duplicate block A. */ | |
80 | basic_block (*duplicate_block) (basic_block a); | |
81 | ||
9ee634e3 JH |
82 | /* Higher level functions representable by primitive operations above if |
83 | we didn't have some oddities in RTL and Tree representations. */ | |
f470c378 ZD |
84 | basic_block (*split_edge) (edge); |
85 | void (*make_forwarder_block) (edge); | |
86 | ||
cf103ca4 | 87 | /* Try to make the edge fallthru. */ |
f470c378 | 88 | void (*tidy_fallthru_edge) (edge); |
6de9cd9a | 89 | |
cf103ca4 EB |
90 | /* Make the edge non-fallthru. */ |
91 | basic_block (*force_nonfallthru) (edge); | |
92 | ||
6de9cd9a DN |
93 | /* Say whether a block ends with a call, possibly followed by some |
94 | other code that must stay with the call. */ | |
b48d0358 | 95 | bool (*block_ends_with_call_p) (basic_block); |
6de9cd9a DN |
96 | |
97 | /* Say whether a block ends with a conditional branch. Switches | |
98 | and unconditional branches do not qualify. */ | |
9678086d | 99 | bool (*block_ends_with_condjump_p) (const_basic_block); |
6de9cd9a DN |
100 | |
101 | /* Add fake edges to the function exit for any non constant and non noreturn | |
102 | calls, volatile inline assembly in the bitmap of blocks specified by | |
103 | BLOCKS or to the whole CFG if BLOCKS is zero. Return the number of blocks | |
104 | that were split. | |
105 | ||
106 | The goal is to expose cases in which entering a basic block does not imply | |
107 | that all subsequent instructions must be executed. */ | |
108 | int (*flow_call_edges_add) (sbitmap); | |
d9d4706f KH |
109 | |
110 | /* This function is called immediately after edge E is added to the | |
111 | edge vector E->dest->preds. */ | |
112 | void (*execute_on_growing_pred) (edge); | |
113 | ||
114 | /* This function is called immediately before edge E is removed from | |
115 | the edge vector E->dest->preds. */ | |
116 | void (*execute_on_shrinking_pred) (edge); | |
1cb7dfc3 MH |
117 | |
118 | /* A hook for duplicating loop in CFG, currently this is used | |
119 | in loop versioning. */ | |
ee8c1b05 ZD |
120 | bool (*cfg_hook_duplicate_loop_to_header_edge) (struct loop *, edge, |
121 | unsigned, sbitmap, | |
122 | edge, VEC (edge, heap) **, | |
123 | int); | |
1cb7dfc3 | 124 | |
0fa2e4df | 125 | /* Add condition to new basic block and update CFG used in loop |
1cb7dfc3 MH |
126 | versioning. */ |
127 | void (*lv_add_condition_to_bb) (basic_block, basic_block, basic_block, | |
c22cacf3 | 128 | void *); |
1cb7dfc3 MH |
129 | /* Update the PHI nodes in case of loop versioning. */ |
130 | void (*lv_adjust_loop_header_phi) (basic_block, basic_block, | |
131 | basic_block, edge); | |
c22cacf3 | 132 | |
1cb7dfc3 MH |
133 | /* Given a condition BB extract the true/false taken/not taken edges |
134 | (depending if we are on tree's or RTL). */ | |
135 | void (*extract_cond_bb_edges) (basic_block, edge *, edge *); | |
136 | ||
c22cacf3 | 137 | |
1cb7dfc3 MH |
138 | /* Add PHI arguments queued in PENDINT_STMT list on edge E to edge |
139 | E->dest (only in tree-ssa loop versioning. */ | |
140 | void (*flush_pending_stmts) (edge); | |
df92c640 SB |
141 | |
142 | /* True if a block contains no executable instructions. */ | |
143 | bool (*empty_block_p) (basic_block); | |
144 | ||
145 | /* Split a basic block if it ends with a conditional branch and if | |
146 | the other part of the block is not empty. */ | |
147 | basic_block (*split_block_before_cond_jump) (basic_block); | |
9ee634e3 JH |
148 | }; |
149 | ||
f470c378 | 150 | extern void verify_flow_info (void); |
a315c44c | 151 | extern void dump_bb (FILE *, basic_block, int, int); |
6de9cd9a | 152 | extern edge redirect_edge_and_branch (edge, basic_block); |
f470c378 | 153 | extern basic_block redirect_edge_and_branch_force (edge, basic_block); |
9678086d | 154 | extern bool can_remove_branch_p (const_edge); |
14fa2cc0 | 155 | extern void remove_branch (edge); |
452ba14d | 156 | extern void remove_edge (edge); |
f470c378 ZD |
157 | extern edge split_block (basic_block, void *); |
158 | extern edge split_block_after_labels (basic_block); | |
159 | extern bool move_block_after (basic_block, basic_block); | |
160 | extern void delete_basic_block (basic_block); | |
161 | extern basic_block split_edge (edge); | |
162 | extern basic_block create_basic_block (void *, void *, basic_block); | |
163 | extern basic_block create_empty_bb (basic_block); | |
b48d0358 | 164 | extern bool can_merge_blocks_p (basic_block, basic_block); |
f470c378 ZD |
165 | extern void merge_blocks (basic_block, basic_block); |
166 | extern edge make_forwarder_block (basic_block, bool (*)(edge), | |
167 | void (*) (basic_block)); | |
cf103ca4 | 168 | extern basic_block force_nonfallthru (edge); |
f470c378 ZD |
169 | extern void tidy_fallthru_edge (edge); |
170 | extern void tidy_fallthru_edges (void); | |
6de9cd9a | 171 | extern void predict_edge (edge e, enum br_predictor predictor, int probability); |
9678086d KG |
172 | extern bool predicted_by_p (const_basic_block bb, enum br_predictor predictor); |
173 | extern bool can_duplicate_block_p (const_basic_block); | |
b9a66240 | 174 | extern basic_block duplicate_block (basic_block, edge, basic_block); |
b48d0358 | 175 | extern bool block_ends_with_call_p (basic_block bb); |
df92c640 SB |
176 | extern bool empty_block_p (basic_block); |
177 | extern basic_block split_block_before_cond_jump (basic_block); | |
9678086d | 178 | extern bool block_ends_with_condjump_p (const_basic_block bb); |
6de9cd9a | 179 | extern int flow_call_edges_add (sbitmap); |
d9d4706f KH |
180 | extern void execute_on_growing_pred (edge); |
181 | extern void execute_on_shrinking_pred (edge); | |
1cb7dfc3 | 182 | extern bool cfg_hook_duplicate_loop_to_header_edge (struct loop *loop, edge, |
1cb7dfc3 MH |
183 | unsigned int ndupl, |
184 | sbitmap wont_exit, | |
ee8c1b05 ZD |
185 | edge orig, |
186 | VEC (edge, heap) **to_remove, | |
1cb7dfc3 MH |
187 | int flags); |
188 | ||
189 | extern void lv_flush_pending_stmts (edge); | |
190 | extern void extract_cond_bb_edges (basic_block, edge *, edge*); | |
191 | extern void lv_adjust_loop_header_phi (basic_block, basic_block, basic_block, | |
192 | edge); | |
193 | extern void lv_add_condition_to_bb (basic_block, basic_block, basic_block, | |
194 | void *); | |
9ee634e3 | 195 | |
78bde837 SB |
196 | extern bool can_copy_bbs_p (basic_block *, unsigned); |
197 | extern void copy_bbs (basic_block *, unsigned, basic_block *, | |
198 | edge *, unsigned, edge *, struct loop *, | |
199 | basic_block); | |
200 | ||
201 | extern void cfg_layout_initialize (unsigned int); | |
202 | extern void cfg_layout_finalize (void); | |
203 | ||
9ee634e3 | 204 | /* Hooks containers. */ |
726a989a | 205 | extern struct cfg_hooks gimple_cfg_hooks; |
9ee634e3 | 206 | extern struct cfg_hooks rtl_cfg_hooks; |
f470c378 | 207 | extern struct cfg_hooks cfg_layout_rtl_cfg_hooks; |
9ee634e3 JH |
208 | |
209 | /* Declarations. */ | |
52bca999 | 210 | extern enum ir_type current_ir_type (void); |
d329e058 AJ |
211 | extern void rtl_register_cfg_hooks (void); |
212 | extern void cfg_layout_rtl_register_cfg_hooks (void); | |
726a989a | 213 | extern void gimple_register_cfg_hooks (void); |
e855c69d AB |
214 | extern struct cfg_hooks get_cfg_hooks (void); |
215 | extern void set_cfg_hooks (struct cfg_hooks); | |
9ee634e3 | 216 |