* config/i386/i386.md (fmodxf3): Enable for flag_finite_math_only only.
[official-gcc.git] / gcc / cfghooks.h
blob1b8587a5b1bd71afc8515259139ad08c8379f4b9
1 /* Hooks for cfg representation specific functions.
2 Copyright (C) 2003-2014 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <s.pop@laposte.net>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_CFGHOOKS_H
22 #define GCC_CFGHOOKS_H
24 /* Only basic-block.h includes this. */
26 struct cfg_hooks
28 /* Name of the corresponding ir. */
29 const char *name;
31 /* Debugging. */
32 int (*verify_flow_info) (void);
33 void (*dump_bb) (FILE *, basic_block, int, int);
34 void (*dump_bb_for_graph) (pretty_printer *, basic_block);
36 /* Basic CFG manipulation. */
38 /* Return new basic block. */
39 basic_block (*create_basic_block) (void *head, void *end, basic_block after);
41 /* Redirect edge E to the given basic block B and update underlying program
42 representation. Returns edge representing redirected branch (that may not
43 be equivalent to E in the case of duplicate edges being removed) or NULL
44 if edge is not easily redirectable for whatever reason. */
45 edge (*redirect_edge_and_branch) (edge e, basic_block b);
47 /* Same as the above but allows redirecting of fallthru edges. In that case
48 newly created forwarder basic block is returned. The edge must
49 not be abnormal. */
50 basic_block (*redirect_edge_and_branch_force) (edge, basic_block);
52 /* Returns true if it is possible to remove the edge by redirecting it
53 to the destination of the other edge going from its source. */
54 bool (*can_remove_branch_p) (const_edge);
56 /* Remove statements corresponding to a given basic block. */
57 void (*delete_basic_block) (basic_block);
59 /* Creates a new basic block just after basic block B by splitting
60 everything after specified instruction I. */
61 basic_block (*split_block) (basic_block b, void * i);
63 /* Move block B immediately after block A. */
64 bool (*move_block_after) (basic_block b, basic_block a);
66 /* Return true when blocks A and B can be merged into single basic block. */
67 bool (*can_merge_blocks_p) (basic_block a, basic_block b);
69 /* Merge blocks A and B. */
70 void (*merge_blocks) (basic_block a, basic_block b);
72 /* Predict edge E using PREDICTOR to given PROBABILITY. */
73 void (*predict_edge) (edge e, enum br_predictor predictor, int probability);
75 /* Return true if the one of outgoing edges is already predicted by
76 PREDICTOR. */
77 bool (*predicted_by_p) (const_basic_block bb, enum br_predictor predictor);
79 /* Return true when block A can be duplicated. */
80 bool (*can_duplicate_block_p) (const_basic_block a);
82 /* Duplicate block A. */
83 basic_block (*duplicate_block) (basic_block a);
85 /* Higher level functions representable by primitive operations above if
86 we didn't have some oddities in RTL and Tree representations. */
87 basic_block (*split_edge) (edge);
88 void (*make_forwarder_block) (edge);
90 /* Try to make the edge fallthru. */
91 void (*tidy_fallthru_edge) (edge);
93 /* Make the edge non-fallthru. */
94 basic_block (*force_nonfallthru) (edge);
96 /* Say whether a block ends with a call, possibly followed by some
97 other code that must stay with the call. */
98 bool (*block_ends_with_call_p) (basic_block);
100 /* Say whether a block ends with a conditional branch. Switches
101 and unconditional branches do not qualify. */
102 bool (*block_ends_with_condjump_p) (const_basic_block);
104 /* Add fake edges to the function exit for any non constant and non noreturn
105 calls, volatile inline assembly in the bitmap of blocks specified by
106 BLOCKS or to the whole CFG if BLOCKS is zero. Return the number of blocks
107 that were split.
109 The goal is to expose cases in which entering a basic block does not imply
110 that all subsequent instructions must be executed. */
111 int (*flow_call_edges_add) (sbitmap);
113 /* This function is called immediately after edge E is added to the
114 edge vector E->dest->preds. */
115 void (*execute_on_growing_pred) (edge);
117 /* This function is called immediately before edge E is removed from
118 the edge vector E->dest->preds. */
119 void (*execute_on_shrinking_pred) (edge);
121 /* A hook for duplicating loop in CFG, currently this is used
122 in loop versioning. */
123 bool (*cfg_hook_duplicate_loop_to_header_edge) (struct loop *, edge,
124 unsigned, sbitmap,
125 edge, vec<edge> *,
126 int);
128 /* Add condition to new basic block and update CFG used in loop
129 versioning. */
130 void (*lv_add_condition_to_bb) (basic_block, basic_block, basic_block,
131 void *);
132 /* Update the PHI nodes in case of loop versioning. */
133 void (*lv_adjust_loop_header_phi) (basic_block, basic_block,
134 basic_block, edge);
136 /* Given a condition BB extract the true/false taken/not taken edges
137 (depending if we are on tree's or RTL). */
138 void (*extract_cond_bb_edges) (basic_block, edge *, edge *);
141 /* Add PHI arguments queued in PENDINT_STMT list on edge E to edge
142 E->dest (only in tree-ssa loop versioning. */
143 void (*flush_pending_stmts) (edge);
145 /* True if a block contains no executable instructions. */
146 bool (*empty_block_p) (basic_block);
148 /* Split a basic block if it ends with a conditional branch and if
149 the other part of the block is not empty. */
150 basic_block (*split_block_before_cond_jump) (basic_block);
152 /* Do book-keeping of a basic block for the profile consistency checker. */
153 void (*account_profile_record) (basic_block, int, struct profile_record *);
156 extern void verify_flow_info (void);
157 extern void dump_bb (FILE *, basic_block, int, int);
158 extern void dump_bb_for_graph (pretty_printer *, basic_block);
160 extern edge redirect_edge_and_branch (edge, basic_block);
161 extern basic_block redirect_edge_and_branch_force (edge, basic_block);
162 extern bool can_remove_branch_p (const_edge);
163 extern void remove_branch (edge);
164 extern void remove_edge (edge);
165 extern edge split_block (basic_block, void *);
166 extern edge split_block_after_labels (basic_block);
167 extern bool move_block_after (basic_block, basic_block);
168 extern void delete_basic_block (basic_block);
169 extern basic_block split_edge (edge);
170 extern basic_block create_basic_block (void *, void *, basic_block);
171 extern basic_block create_empty_bb (basic_block);
172 extern bool can_merge_blocks_p (basic_block, basic_block);
173 extern void merge_blocks (basic_block, basic_block);
174 extern edge make_forwarder_block (basic_block, bool (*)(edge),
175 void (*) (basic_block));
176 extern basic_block force_nonfallthru (edge);
177 extern void tidy_fallthru_edge (edge);
178 extern void tidy_fallthru_edges (void);
179 extern void predict_edge (edge e, enum br_predictor predictor, int probability);
180 extern bool predicted_by_p (const_basic_block bb, enum br_predictor predictor);
181 extern bool can_duplicate_block_p (const_basic_block);
182 extern basic_block duplicate_block (basic_block, edge, basic_block);
183 extern bool block_ends_with_call_p (basic_block bb);
184 extern bool empty_block_p (basic_block);
185 extern basic_block split_block_before_cond_jump (basic_block);
186 extern bool block_ends_with_condjump_p (const_basic_block bb);
187 extern int flow_call_edges_add (sbitmap);
188 extern void execute_on_growing_pred (edge);
189 extern void execute_on_shrinking_pred (edge);
190 extern bool cfg_hook_duplicate_loop_to_header_edge (struct loop *loop, edge,
191 unsigned int ndupl,
192 sbitmap wont_exit,
193 edge orig,
194 vec<edge> *to_remove,
195 int flags);
197 extern void lv_flush_pending_stmts (edge);
198 extern void extract_cond_bb_edges (basic_block, edge *, edge*);
199 extern void lv_adjust_loop_header_phi (basic_block, basic_block, basic_block,
200 edge);
201 extern void lv_add_condition_to_bb (basic_block, basic_block, basic_block,
202 void *);
204 extern bool can_copy_bbs_p (basic_block *, unsigned);
205 extern void copy_bbs (basic_block *, unsigned, basic_block *,
206 edge *, unsigned, edge *, struct loop *,
207 basic_block, bool);
209 void account_profile_record (struct profile_record *, int);
211 extern void cfg_layout_initialize (unsigned int);
212 extern void cfg_layout_finalize (void);
214 /* Hooks containers. */
215 extern struct cfg_hooks gimple_cfg_hooks;
216 extern struct cfg_hooks rtl_cfg_hooks;
217 extern struct cfg_hooks cfg_layout_rtl_cfg_hooks;
219 /* Declarations. */
220 extern enum ir_type current_ir_type (void);
221 extern void rtl_register_cfg_hooks (void);
222 extern void cfg_layout_rtl_register_cfg_hooks (void);
223 extern void gimple_register_cfg_hooks (void);
224 extern struct cfg_hooks get_cfg_hooks (void);
225 extern void set_cfg_hooks (struct cfg_hooks);
227 #endif /* GCC_CFGHOOKS_H */