comparison gcc/cfghooks.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Hooks for cfg representation specific functions. 1 /* Hooks for cfg representation specific functions.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 Contributed by Sebastian Pop <s.pop@laposte.net> 3 Contributed by Sebastian Pop <s.pop@laposte.net>
5 4
6 This file is part of GCC. 5 This file is part of GCC.
7 6
8 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
20 <http://www.gnu.org/licenses/>. */ 19 <http://www.gnu.org/licenses/>. */
21 20
22 #ifndef GCC_CFGHOOKS_H 21 #ifndef GCC_CFGHOOKS_H
23 #define GCC_CFGHOOKS_H 22 #define GCC_CFGHOOKS_H
24 23
24 #include "predict.h"
25
26 /* Structure to gather statistic about profile consistency, per pass.
27 An array of this structure, indexed by pass static number, is allocated
28 in passes.c. The structure is defined here so that different CFG modes
29 can do their book-keeping via CFG hooks.
30
31 For every field[2], field[0] is the count before the pass runs, and
32 field[1] is the post-pass count. This allows us to monitor the effect
33 of each individual pass on the profile consistency.
34
35 This structure is not supposed to be used by anything other than passes.c
36 and one CFG hook per CFG mode. */
37 struct profile_record
38 {
39 /* The number of basic blocks where sum(freq) of the block's predecessors
40 doesn't match reasonably well with the incoming frequency. */
41 int num_mismatched_freq_in[2];
42 /* Likewise for a basic block's successors. */
43 int num_mismatched_freq_out[2];
44 /* The number of basic blocks where sum(count) of the block's predecessors
45 doesn't match reasonably well with the incoming frequency. */
46 int num_mismatched_count_in[2];
47 /* Likewise for a basic block's successors. */
48 int num_mismatched_count_out[2];
49 /* A weighted cost of the run-time of the function body. */
50 gcov_type time[2];
51 /* A weighted cost of the size of the function body. */
52 int size[2];
53 /* True iff this pass actually was run. */
54 bool run;
55 };
56
57
25 struct cfg_hooks 58 struct cfg_hooks
26 { 59 {
27 /* Name of the corresponding ir. */ 60 /* Name of the corresponding ir. */
28 const char *name; 61 const char *name;
29 62
30 /* Debugging. */ 63 /* Debugging. */
31 int (*verify_flow_info) (void); 64 int (*verify_flow_info) (void);
32 void (*dump_bb) (basic_block, FILE *, int, int); 65 void (*dump_bb) (FILE *, basic_block, int, dump_flags_t);
66 void (*dump_bb_for_graph) (pretty_printer *, basic_block);
33 67
34 /* Basic CFG manipulation. */ 68 /* Basic CFG manipulation. */
35 69
36 /* Return new basic block. */ 70 /* Return new basic block. */
37 basic_block (*create_basic_block) (void *head, void *end, basic_block after); 71 basic_block (*create_basic_block) (void *head, void *end, basic_block after);
83 /* Higher level functions representable by primitive operations above if 117 /* Higher level functions representable by primitive operations above if
84 we didn't have some oddities in RTL and Tree representations. */ 118 we didn't have some oddities in RTL and Tree representations. */
85 basic_block (*split_edge) (edge); 119 basic_block (*split_edge) (edge);
86 void (*make_forwarder_block) (edge); 120 void (*make_forwarder_block) (edge);
87 121
88 /* Tries to make the edge fallthru. */ 122 /* Try to make the edge fallthru. */
89 void (*tidy_fallthru_edge) (edge); 123 void (*tidy_fallthru_edge) (edge);
124
125 /* Make the edge non-fallthru. */
126 basic_block (*force_nonfallthru) (edge);
90 127
91 /* Say whether a block ends with a call, possibly followed by some 128 /* Say whether a block ends with a call, possibly followed by some
92 other code that must stay with the call. */ 129 other code that must stay with the call. */
93 bool (*block_ends_with_call_p) (basic_block); 130 bool (*block_ends_with_call_p) (basic_block);
94 131
115 152
116 /* A hook for duplicating loop in CFG, currently this is used 153 /* A hook for duplicating loop in CFG, currently this is used
117 in loop versioning. */ 154 in loop versioning. */
118 bool (*cfg_hook_duplicate_loop_to_header_edge) (struct loop *, edge, 155 bool (*cfg_hook_duplicate_loop_to_header_edge) (struct loop *, edge,
119 unsigned, sbitmap, 156 unsigned, sbitmap,
120 edge, VEC (edge, heap) **, 157 edge, vec<edge> *,
121 int); 158 int);
122 159
123 /* Add condition to new basic block and update CFG used in loop 160 /* Add condition to new basic block and update CFG used in loop
124 versioning. */ 161 versioning. */
125 void (*lv_add_condition_to_bb) (basic_block, basic_block, basic_block, 162 void (*lv_add_condition_to_bb) (basic_block, basic_block, basic_block,
134 171
135 172
136 /* Add PHI arguments queued in PENDINT_STMT list on edge E to edge 173 /* Add PHI arguments queued in PENDINT_STMT list on edge E to edge
137 E->dest (only in tree-ssa loop versioning. */ 174 E->dest (only in tree-ssa loop versioning. */
138 void (*flush_pending_stmts) (edge); 175 void (*flush_pending_stmts) (edge);
176
177 /* True if a block contains no executable instructions. */
178 bool (*empty_block_p) (basic_block);
179
180 /* Split a basic block if it ends with a conditional branch and if
181 the other part of the block is not empty. */
182 basic_block (*split_block_before_cond_jump) (basic_block);
183
184 /* Do book-keeping of a basic block for the profile consistency checker. */
185 void (*account_profile_record) (basic_block, int, struct profile_record *);
139 }; 186 };
140 187
141 extern void verify_flow_info (void); 188 extern void verify_flow_info (void);
142 extern void dump_bb (basic_block, FILE *, int); 189
190 /* Check control flow invariants, if internal consistency checks are
191 enabled. */
192
193 static inline void
194 checking_verify_flow_info (void)
195 {
196 /* TODO: Add a separate option for -fchecking=cfg. */
197 if (flag_checking)
198 verify_flow_info ();
199 }
200
201 extern void dump_bb (FILE *, basic_block, int, dump_flags_t);
202 extern void dump_bb_for_graph (pretty_printer *, basic_block);
203 extern void dump_flow_info (FILE *, dump_flags_t);
204
143 extern edge redirect_edge_and_branch (edge, basic_block); 205 extern edge redirect_edge_and_branch (edge, basic_block);
144 extern basic_block redirect_edge_and_branch_force (edge, basic_block); 206 extern basic_block redirect_edge_and_branch_force (edge, basic_block);
207 extern edge redirect_edge_succ_nodup (edge, basic_block);
145 extern bool can_remove_branch_p (const_edge); 208 extern bool can_remove_branch_p (const_edge);
146 extern void remove_branch (edge); 209 extern void remove_branch (edge);
147 extern void remove_edge (edge); 210 extern void remove_edge (edge);
148 extern edge split_block (basic_block, void *); 211 extern edge split_block (basic_block, rtx);
212 extern edge split_block (basic_block, gimple *);
149 extern edge split_block_after_labels (basic_block); 213 extern edge split_block_after_labels (basic_block);
150 extern bool move_block_after (basic_block, basic_block); 214 extern bool move_block_after (basic_block, basic_block);
151 extern void delete_basic_block (basic_block); 215 extern void delete_basic_block (basic_block);
152 extern basic_block split_edge (edge); 216 extern basic_block split_edge (edge);
153 extern basic_block create_basic_block (void *, void *, basic_block); 217 extern basic_block create_basic_block (rtx, rtx, basic_block);
218 extern basic_block create_basic_block (gimple_seq, basic_block);
154 extern basic_block create_empty_bb (basic_block); 219 extern basic_block create_empty_bb (basic_block);
155 extern bool can_merge_blocks_p (basic_block, basic_block); 220 extern bool can_merge_blocks_p (basic_block, basic_block);
156 extern void merge_blocks (basic_block, basic_block); 221 extern void merge_blocks (basic_block, basic_block);
157 extern edge make_forwarder_block (basic_block, bool (*)(edge), 222 extern edge make_forwarder_block (basic_block, bool (*)(edge),
158 void (*) (basic_block)); 223 void (*) (basic_block));
224 extern basic_block force_nonfallthru (edge);
159 extern void tidy_fallthru_edge (edge); 225 extern void tidy_fallthru_edge (edge);
160 extern void tidy_fallthru_edges (void); 226 extern void tidy_fallthru_edges (void);
161 extern void predict_edge (edge e, enum br_predictor predictor, int probability); 227 extern void predict_edge (edge e, enum br_predictor predictor, int probability);
162 extern bool predicted_by_p (const_basic_block bb, enum br_predictor predictor); 228 extern bool predicted_by_p (const_basic_block bb, enum br_predictor predictor);
163 extern bool can_duplicate_block_p (const_basic_block); 229 extern bool can_duplicate_block_p (const_basic_block);
164 extern basic_block duplicate_block (basic_block, edge, basic_block); 230 extern basic_block duplicate_block (basic_block, edge, basic_block);
165 extern bool block_ends_with_call_p (basic_block bb); 231 extern bool block_ends_with_call_p (basic_block bb);
232 extern bool empty_block_p (basic_block);
233 extern basic_block split_block_before_cond_jump (basic_block);
166 extern bool block_ends_with_condjump_p (const_basic_block bb); 234 extern bool block_ends_with_condjump_p (const_basic_block bb);
167 extern int flow_call_edges_add (sbitmap); 235 extern int flow_call_edges_add (sbitmap);
168 extern void execute_on_growing_pred (edge); 236 extern void execute_on_growing_pred (edge);
169 extern void execute_on_shrinking_pred (edge); 237 extern void execute_on_shrinking_pred (edge);
170 extern bool cfg_hook_duplicate_loop_to_header_edge (struct loop *loop, edge, 238 extern bool cfg_hook_duplicate_loop_to_header_edge (struct loop *loop, edge,
171 unsigned int ndupl, 239 unsigned int ndupl,
172 sbitmap wont_exit, 240 sbitmap wont_exit,
173 edge orig, 241 edge orig,
174 VEC (edge, heap) **to_remove, 242 vec<edge> *to_remove,
175 int flags); 243 int flags);
176 244
177 extern void lv_flush_pending_stmts (edge); 245 extern void lv_flush_pending_stmts (edge);
178 extern void extract_cond_bb_edges (basic_block, edge *, edge*); 246 extern void extract_cond_bb_edges (basic_block, edge *, edge*);
179 extern void lv_adjust_loop_header_phi (basic_block, basic_block, basic_block, 247 extern void lv_adjust_loop_header_phi (basic_block, basic_block, basic_block,
180 edge); 248 edge);
181 extern void lv_add_condition_to_bb (basic_block, basic_block, basic_block, 249 extern void lv_add_condition_to_bb (basic_block, basic_block, basic_block,
182 void *); 250 void *);
251
252 extern bool can_copy_bbs_p (basic_block *, unsigned);
253 extern void copy_bbs (basic_block *, unsigned, basic_block *,
254 edge *, unsigned, edge *, struct loop *,
255 basic_block, bool);
256
257 void account_profile_record (struct profile_record *, int);
183 258
184 /* Hooks containers. */ 259 /* Hooks containers. */
185 extern struct cfg_hooks gimple_cfg_hooks; 260 extern struct cfg_hooks gimple_cfg_hooks;
186 extern struct cfg_hooks rtl_cfg_hooks; 261 extern struct cfg_hooks rtl_cfg_hooks;
187 extern struct cfg_hooks cfg_layout_rtl_cfg_hooks; 262 extern struct cfg_hooks cfg_layout_rtl_cfg_hooks;
192 extern void cfg_layout_rtl_register_cfg_hooks (void); 267 extern void cfg_layout_rtl_register_cfg_hooks (void);
193 extern void gimple_register_cfg_hooks (void); 268 extern void gimple_register_cfg_hooks (void);
194 extern struct cfg_hooks get_cfg_hooks (void); 269 extern struct cfg_hooks get_cfg_hooks (void);
195 extern void set_cfg_hooks (struct cfg_hooks); 270 extern void set_cfg_hooks (struct cfg_hooks);
196 271
197 #endif /* GCC_CFGHOOKS_H */ 272 #endif /* GCC_CFGHOOKS_H */