00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GCC_CGRAPH_H
00023 #define GCC_CGRAPH_H
00024 #include "tree.h"
00025 #include "basic-block.h"
00026
00027 enum availability
00028 {
00029
00030 AVAIL_UNSET,
00031
00032 AVAIL_NOT_AVAILABLE,
00033
00034
00035
00036
00037
00038 AVAIL_OVERWRITABLE,
00039
00040
00041 AVAIL_AVAILABLE,
00042
00043
00044
00045
00046 AVAIL_LOCAL
00047 };
00048
00049
00050
00051
00052 struct cgraph_local_info GTY(())
00053 {
00054
00055 int self_insns;
00056
00057
00058
00059 unsigned local : 1;
00060
00061
00062 unsigned externally_visible : 1;
00063
00064
00065 unsigned finalized : 1;
00066
00067
00068 unsigned inlinable : 1;
00069
00070
00071 unsigned disregard_inline_limits : 1;
00072
00073
00074
00075 unsigned redefined_extern_inline : 1;
00076
00077
00078
00079 unsigned for_functions_valid : 1;
00080
00081
00082
00083 unsigned vtable_method : 1;
00084 };
00085
00086
00087
00088
00089 struct cgraph_global_info GTY(())
00090 {
00091
00092 struct cgraph_node *inlined_to;
00093
00094
00095 int insns;
00096
00097
00098 int estimated_growth;
00099
00100
00101 bool inlined;
00102 };
00103
00104
00105
00106
00107 struct cgraph_rtl_info GTY(())
00108 {
00109 int preferred_incoming_stack_boundary;
00110 };
00111
00112
00113
00114
00115 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
00116 {
00117 tree decl;
00118 struct cgraph_edge *callees;
00119 struct cgraph_edge *callers;
00120 struct cgraph_node *next;
00121 struct cgraph_node *previous;
00122 /* For nested functions points to function the node is nested in. */
00123 struct cgraph_node *origin;
00124 /* Points to first nested function, if any. */
00125 struct cgraph_node *nested;
00126 /* Pointer to the next function with same origin, if any. */
00127 struct cgraph_node *next_nested;
00128 /* Pointer to the next function in cgraph_nodes_queue. */
00129 struct cgraph_node *next_needed;
00130 /* Pointer to the next clone. */
00131 struct cgraph_node *next_clone;
00132 struct cgraph_node *prev_clone;
00133 /* Pointer to a single unique cgraph node for this function. If the
00134 function is to be output, this is the copy that will survive. */
00135 struct cgraph_node *master_clone;
00136 /* For functions with many calls sites it holds map from call expression
00137 to the edge to speed up cgraph_edge function. */
00138 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
00139
00140 PTR GTY ((skip)) aux;
00141
00142 struct cgraph_local_info local;
00143 struct cgraph_global_info global;
00144 struct cgraph_rtl_info rtl;
00145
00146 /* Expected number of executions: calculated in profile.c. */
00147 gcov_type count;
00148 /* Unique id of the node. */
00149 int uid;
00150 /* Ordering of all cgraph nodes. */
00151 int order;
00152
00153 /* Set when function must be output - it is externally visible
00154 or its address is taken. */
00155 unsigned needed : 1;
00156 /* Set when function is reachable by call from other function
00157 that is either reachable or needed. */
00158 unsigned reachable : 1;
00159 /* Set once the function is lowered (i.e. its CFG is built). */
00160 unsigned lowered : 1;
00161 /* Set once the function has been instantiated and its callee
00162 lists created. */
00163 unsigned analyzed : 1;
00164 /* Set when function is scheduled to be assembled. */
00165 unsigned output : 1;
00166 /* Set for aliases once they got through assemble_alias. */
00167 unsigned alias : 1;
00168
00169 /* In non-unit-at-a-time mode the function body of inline candidates is saved
00170 into clone before compiling so the function in original form can be
00171 inlined later. This pointer points to the clone. */
00172 tree inline_decl;
00173 };
00174
00175 struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
00176 {
00177 struct cgraph_node *caller;
00178 struct cgraph_node *callee;
00179 struct cgraph_edge *prev_caller;
00180 struct cgraph_edge *next_caller;
00181 struct cgraph_edge *prev_callee;
00182 struct cgraph_edge *next_callee;
00183 tree call_stmt;
00184 PTR GTY ((skip (""))) aux;
00185 /* When NULL, inline this call. When non-NULL, points to the explanation
00186 why function was not inlined. */
00187 const char *inline_failed;
00188 /* Expected number of executions: calculated in profile.c. */
00189 gcov_type count;
00190 /* Depth of loop nest, 1 means no loop nest. */
00191 int loop_nest;
00192 };
00193
00194 typedef struct cgraph_edge *cgraph_edge_p;
00195
00196 DEF_VEC_P(cgraph_edge_p);
00197 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
00198
00199 /* The cgraph_varpool data structure.
00200 Each static variable decl has assigned cgraph_varpool_node. */
00201
00202 struct cgraph_varpool_node GTY(())
00203 {
00204 tree decl;
00205 /* Pointer to the next function in cgraph_varpool_nodes. */
00206 struct cgraph_varpool_node *next;
00207 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
00208 struct cgraph_varpool_node *next_needed;
00209 /* Ordering of all cgraph nodes. */
00210 int order;
00211
00212 /* Set when function must be output - it is externally visible
00213 or its address is taken. */
00214 unsigned needed : 1;
00215 /* Needed variables might become dead by optimization. This flag
00216 forces the variable to be output even if it appears dead otherwise. */
00217 unsigned force_output : 1;
00218 /* Set once the variable has been instantiated and its callee
00219 lists created. */
00220 unsigned analyzed : 1;
00221 /* Set once it has been finalized so we consider it to be output. */
00222 unsigned finalized : 1;
00223 /* Set when variable is scheduled to be assembled. */
00224 unsigned output : 1;
00225 /* Set when function is visible by other units. */
00226 unsigned externally_visible : 1;
00227 /* Set for aliases once they got through assemble_alias. */
00228 unsigned alias : 1;
00229 };
00230
00231 /* Every top level asm statement is put into a cgraph_asm_node. */
00232
00233 struct cgraph_asm_node GTY(())
00234 {
00235 /* Next asm node. */
00236 struct cgraph_asm_node *next;
00237 /* String for this asm node. */
00238 tree asm_str;
00239 /* Ordering of all cgraph nodes. */
00240 int order;
00241 };
00242
00243 extern GTY(()) struct cgraph_node *cgraph_nodes;
00244 extern GTY(()) int cgraph_n_nodes;
00245 extern GTY(()) int cgraph_max_uid;
00246 extern bool cgraph_global_info_ready;
00247 extern bool cgraph_function_flags_ready;
00248 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
00249 extern GTY(()) struct cgraph_node *cgraph_expand_queue;
00250
00251 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_first_unanalyzed_node;
00252 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_last_needed_node;
00253 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
00254 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes;
00255 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
00256 extern GTY(()) int cgraph_order;
00257
00258 /* In cgraph.c */
00259 void dump_cgraph (FILE *);
00260 void dump_cgraph_node (FILE *, struct cgraph_node *);
00261 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
00262 void dump_varpool (FILE *);
00263 void dump_cgraph_varpool_node (FILE *, struct cgraph_varpool_node *);
00264 void cgraph_remove_edge (struct cgraph_edge *);
00265 void cgraph_remove_node (struct cgraph_node *);
00266 void cgraph_node_remove_callees (struct cgraph_node *node);
00267 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
00268 struct cgraph_node *,
00269 tree, gcov_type, int);
00270 struct cgraph_node *cgraph_node (tree);
00271 struct cgraph_node *cgraph_node_for_asm (tree asmname);
00272 struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree);
00273 void cgraph_set_call_stmt (struct cgraph_edge *, tree);
00274 struct cgraph_local_info *cgraph_local_info (tree);
00275 struct cgraph_global_info *cgraph_global_info (tree);
00276 struct cgraph_rtl_info *cgraph_rtl_info (tree);
00277 const char * cgraph_node_name (struct cgraph_node *);
00278 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
00279 struct cgraph_node *,
00280 tree, gcov_type, int, bool);
00281 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type,
00282 int, bool);
00283
00284 struct cgraph_varpool_node *cgraph_varpool_node (tree);
00285 struct cgraph_varpool_node *cgraph_varpool_node_for_asm (tree asmname);
00286 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
00287 void cgraph_varpool_finalize_decl (tree);
00288 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
00289
00290 struct cgraph_asm_node *cgraph_add_asm_node (tree);
00291
00292 bool cgraph_function_possibly_inlined_p (tree);
00293 void cgraph_unnest_node (struct cgraph_node *);
00294 void cgraph_varpool_enqueue_needed_node (struct cgraph_varpool_node *);
00295 void cgraph_varpool_reset_queue (void);
00296 bool decide_is_variable_needed (struct cgraph_varpool_node *, tree);
00297
00298 enum availability cgraph_function_body_availability (struct cgraph_node *);
00299 enum availability cgraph_variable_initializer_availability (struct cgraph_varpool_node *);
00300 bool cgraph_is_master_clone (struct cgraph_node *);
00301 struct cgraph_node *cgraph_master_clone (struct cgraph_node *);
00302 void cgraph_add_new_function (tree);
00303
00304 /* In cgraphunit.c */
00305 bool cgraph_assemble_pending_functions (void);
00306 bool cgraph_varpool_assemble_pending_decls (void);
00307 void cgraph_finalize_function (tree, bool);
00308 void cgraph_finalize_compilation_unit (void);
00309 void cgraph_optimize (void);
00310 void cgraph_mark_needed_node (struct cgraph_node *);
00311 void cgraph_mark_reachable_node (struct cgraph_node *);
00312 bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
00313 bool cgraph_preserve_function_body_p (tree);
00314 void verify_cgraph (void);
00315 void verify_cgraph_node (struct cgraph_node *);
00316 void cgraph_build_static_cdtor (char which, tree body, int priority);
00317 void cgraph_reset_static_var_maps (void);
00318 void init_cgraph (void);
00319 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
00320 VEC(cgraph_edge_p,heap)*,
00321 varray_type);
00322 void cgraph_analyze_function (struct cgraph_node *);
00323 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
00324 #ifdef KEY
00325 void cgraph_output_pending_asms (void);
00326 #endif
00327
00328 /* In ipa.c */
00329 bool cgraph_remove_unreachable_nodes (bool, FILE *);
00330 int cgraph_postorder (struct cgraph_node **);
00331
00332 /* In ipa-inline.c */
00333 bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool);
00334 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
00335 void cgraph_mark_inline_edge (struct cgraph_edge *, bool);
00336 bool cgraph_default_inline_p (struct cgraph_node *, const char **);
00337 #endif /* GCC_CGRAPH_H */