Mark ChangeLog
[official-gcc.git] / gcc / cfghooks.h
blob92a458ed4aa73e6f572c925d61e25efb5d2fcc80
1 /* Hooks for cfg representation specific functions.
2 Copyright (C) 2003, 2004 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 2, 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 COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #ifndef GCC_CFGHOOKS_H
23 #define GCC_CFGHOOKS_H
25 struct cfg_hooks
27 /* Name of the corresponding ir. */
28 const char *name;
30 /* Debugging. */
31 int (*verify_flow_info) (void);
32 void (*dump_bb) (basic_block, FILE *, int);
34 /* Basic CFG manipulation. */
36 /* Return new basic block. */
37 basic_block (*create_basic_block) (void *head, void *end, basic_block after);
39 /* Redirect edge E to the given basic block B and update underlying program
40 representation. Returns edge representing redirected branch (that may not
41 be equivalent to E in the case of duplicate edges being removed) or NULL
42 if edge is not easily redirectable for whatever reason. */
43 edge (*redirect_edge_and_branch) (edge e, basic_block b);
45 /* Same as the above but allows redirecting of fallthru edges. In that case
46 newly created forwarder basic block is returned. It aborts when called
47 on abnormal edge. */
48 basic_block (*redirect_edge_and_branch_force) (edge, basic_block);
50 /* Remove statements corresponding to a given basic block. */
51 void (*delete_basic_block) (basic_block);
53 /* Creates a new basic block just after basic block B by splitting
54 everything after specified instruction I. */
55 basic_block (*split_block) (basic_block b, void * i);
57 /* Move block B immediately after block A. */
58 bool (*move_block_after) (basic_block b, basic_block a);
60 /* Return true when blocks A and B can be merged into single basic block. */
61 bool (*can_merge_blocks_p) (basic_block a, basic_block b);
63 /* Merge blocks A and B. */
64 void (*merge_blocks) (basic_block a, basic_block b);
66 /* Predict edge E using PREDICTOR to given PROBABILITY. */
67 void (*predict_edge) (edge e, enum br_predictor predictor, int probability);
69 /* Return true if the one of outgoing edges is already predicted by
70 PREDICTOR. */
71 bool (*predicted_by_p) (basic_block bb, enum br_predictor predictor);
73 /* Return true when block A can be duplicated. */
74 bool (*can_duplicate_block_p) (basic_block a);
76 /* Duplicate block A. */
77 basic_block (*duplicate_block) (basic_block a);
79 /* Higher level functions representable by primitive operations above if
80 we didn't have some oddities in RTL and Tree representations. */
81 basic_block (*split_edge) (edge);
82 void (*make_forwarder_block) (edge);
84 /* Tries to make the edge fallthru. */
85 void (*tidy_fallthru_edge) (edge);
87 /* Say whether a block ends with a call, possibly followed by some
88 other code that must stay with the call. */
89 bool (*block_ends_with_call_p) (basic_block);
91 /* Say whether a block ends with a conditional branch. Switches
92 and unconditional branches do not qualify. */
93 bool (*block_ends_with_condjump_p) (basic_block);
95 /* Add fake edges to the function exit for any non constant and non noreturn
96 calls, volatile inline assembly in the bitmap of blocks specified by
97 BLOCKS or to the whole CFG if BLOCKS is zero. Return the number of blocks
98 that were split.
100 The goal is to expose cases in which entering a basic block does not imply
101 that all subsequent instructions must be executed. */
102 int (*flow_call_edges_add) (sbitmap);
104 /* This function is called immediately after edge E is added to the
105 edge vector E->dest->preds. */
106 void (*execute_on_growing_pred) (edge);
108 /* This function is called immediately before edge E is removed from
109 the edge vector E->dest->preds. */
110 void (*execute_on_shrinking_pred) (edge);
113 extern void verify_flow_info (void);
114 extern void dump_bb (basic_block, FILE *, int);
115 extern edge redirect_edge_and_branch (edge, basic_block);
116 extern basic_block redirect_edge_and_branch_force (edge, basic_block);
117 extern edge split_block (basic_block, void *);
118 extern edge split_block_after_labels (basic_block);
119 extern bool move_block_after (basic_block, basic_block);
120 extern void delete_basic_block (basic_block);
121 extern basic_block split_edge (edge);
122 extern basic_block create_basic_block (void *, void *, basic_block);
123 extern basic_block create_empty_bb (basic_block);
124 extern bool can_merge_blocks_p (basic_block, basic_block);
125 extern void merge_blocks (basic_block, basic_block);
126 extern edge make_forwarder_block (basic_block, bool (*)(edge),
127 void (*) (basic_block));
128 extern void tidy_fallthru_edge (edge);
129 extern void tidy_fallthru_edges (void);
130 extern void predict_edge (edge e, enum br_predictor predictor, int probability);
131 extern bool predicted_by_p (basic_block bb, enum br_predictor predictor);
132 extern bool can_duplicate_block_p (basic_block);
133 extern basic_block duplicate_block (basic_block, edge);
134 extern bool block_ends_with_call_p (basic_block bb);
135 extern bool block_ends_with_condjump_p (basic_block bb);
136 extern int flow_call_edges_add (sbitmap);
137 extern void execute_on_growing_pred (edge);
138 extern void execute_on_shrinking_pred (edge);
140 /* Hooks containers. */
141 extern struct cfg_hooks tree_cfg_hooks;
142 extern struct cfg_hooks rtl_cfg_hooks;
143 extern struct cfg_hooks cfg_layout_rtl_cfg_hooks;
145 /* Declarations. */
146 extern int ir_type (void);
147 extern void rtl_register_cfg_hooks (void);
148 extern void cfg_layout_rtl_register_cfg_hooks (void);
149 extern void tree_register_cfg_hooks (void);
151 #endif /* GCC_CFGHOOKS_H */