libiberty.h (ACONCAT): Properly cast value of alloca().
[official-gcc.git] / gcc / cgraph.h
blob294b690787b3601149df1887c9e8a9a0e939170d
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H
24 #include "tree.h"
25 #include "basic-block.h"
27 /* Information about the function collected locally.
28 Available after function is analyzed. */
30 struct cgraph_local_info GTY(())
32 /* Size of the function before inlining. */
33 int self_insns;
35 /* Set when function function is visible in current compilation unit only
36 and its address is never taken. */
37 bool local;
39 /* Set once it has been finalized so we consider it to be output. */
40 bool finalized;
42 /* False when there something makes inlining impossible (such as va_arg). */
43 bool inlinable;
45 /* True when function should be inlined independently on its size. */
46 bool disregard_inline_limits;
48 /* True when the function has been originally extern inline, but it is
49 redefined now. */
50 bool redefined_extern_inline;
52 /* True if statics_read_for_function and
53 statics_written_for_function contain valid data. */
54 bool for_functions_valid;
56 /* True if the function is going to be emitted in some other translation
57 unit, referenced from vtable. */
58 bool vtable_method;
61 /* Information about the function that needs to be computed globally
62 once compilation is finished. Available only with -funit-at-time. */
64 struct cgraph_global_info GTY(())
66 /* For inline clones this points to the function they will be inlined into. */
67 struct cgraph_node *inlined_to;
69 /* Estimated size of the function after inlining. */
70 int insns;
72 /* Set iff the function has been inlined at least once. */
73 bool inlined;
76 /* Information about the function that is propagated by the RTL backend.
77 Available only for functions that has been already assembled. */
79 struct cgraph_rtl_info GTY(())
81 int preferred_incoming_stack_boundary;
82 bool const_function;
83 bool pure_function;
86 /* The cgraph data structure.
87 Each function decl has assigned cgraph_node listing callees and callers. */
89 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
91 tree decl;
92 struct cgraph_edge *callees;
93 struct cgraph_edge *callers;
94 struct cgraph_node *next;
95 struct cgraph_node *previous;
96 /* For nested functions points to function the node is nested in. */
97 struct cgraph_node *origin;
98 /* Points to first nested function, if any. */
99 struct cgraph_node *nested;
100 /* Pointer to the next function with same origin, if any. */
101 struct cgraph_node *next_nested;
102 /* Pointer to the next function in cgraph_nodes_queue. */
103 struct cgraph_node *next_needed;
104 /* Pointer to the next clone. */
105 struct cgraph_node *next_clone;
106 struct cgraph_node *prev_clone;
107 PTR GTY ((skip)) aux;
109 struct cgraph_local_info local;
110 struct cgraph_global_info global;
111 struct cgraph_rtl_info rtl;
113 /* Expected number of executions: calculated in profile.c. */
114 gcov_type count;
115 /* Unique id of the node. */
116 int uid;
117 /* Set when function must be output - it is externally visible
118 or its address is taken. */
119 bool needed;
120 /* Set when function is reachable by call from other function
121 that is either reachable or needed. */
122 bool reachable;
123 /* Set once the function is lowered (ie it's CFG is built). */
124 bool lowered;
125 /* Set once the function has been instantiated and its callee
126 lists created. */
127 bool analyzed;
128 /* Set when function is scheduled to be assembled. */
129 bool output;
130 /* Set for aliases once they got through assemble_alias. */
131 bool alias;
134 struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
136 struct cgraph_node *caller;
137 struct cgraph_node *callee;
138 struct cgraph_edge *prev_caller;
139 struct cgraph_edge *next_caller;
140 struct cgraph_edge *prev_callee;
141 struct cgraph_edge *next_callee;
142 tree call_expr;
143 PTR GTY ((skip (""))) aux;
144 /* When NULL, inline this call. When non-NULL, points to the explanation
145 why function was not inlined. */
146 const char *inline_failed;
147 /* Expected number of executions: calculated in profile.c. */
148 gcov_type count;
149 /* Depth of loop nest, 1 means no loop nest. */
150 int loop_nest;
153 /* The cgraph_varpool data structure.
154 Each static variable decl has assigned cgraph_varpool_node. */
156 struct cgraph_varpool_node GTY(())
158 tree decl;
159 /* Pointer to the next function in cgraph_varpool_nodes. */
160 struct cgraph_varpool_node *next;
161 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
162 struct cgraph_varpool_node *next_needed;
164 /* Set when function must be output - it is externally visible
165 or its address is taken. */
166 bool needed;
167 /* Needed variables might become dead by optimization. This flag
168 forces the variable to be output even if it appears dead otherwise. */
169 bool force_output;
170 /* Set once the variable has been instantiated and its callee
171 lists created. */
172 bool analyzed;
173 /* Set once it has been finalized so we consider it to be output. */
174 bool finalized;
175 /* Set when function is scheduled to be assembled. */
176 bool output;
177 /* Set for aliases once they got through assemble_alias. */
178 bool alias;
181 extern GTY(()) struct cgraph_node *cgraph_nodes;
182 extern GTY(()) int cgraph_n_nodes;
183 extern GTY(()) int cgraph_max_uid;
184 extern bool cgraph_global_info_ready;
185 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
187 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_first_unanalyzed_node;
188 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
190 /* In cgraph.c */
191 void dump_cgraph (FILE *);
192 void dump_cgraph_node (FILE *, struct cgraph_node *);
193 void dump_varpool (FILE *);
194 void dump_cgraph_varpool_node (FILE *, struct cgraph_varpool_node *);
195 void cgraph_remove_edge (struct cgraph_edge *);
196 void cgraph_remove_node (struct cgraph_node *);
197 void cgraph_node_remove_callees (struct cgraph_node *node);
198 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
199 struct cgraph_node *,
200 tree, gcov_type, int);
201 struct cgraph_node *cgraph_node (tree);
202 struct cgraph_node *cgraph_node_for_asm (tree asmname);
203 struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree);
204 struct cgraph_local_info *cgraph_local_info (tree);
205 struct cgraph_global_info *cgraph_global_info (tree);
206 struct cgraph_rtl_info *cgraph_rtl_info (tree);
207 const char * cgraph_node_name (struct cgraph_node *);
208 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, struct cgraph_node *, tree, int, int);
209 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int);
211 struct cgraph_varpool_node *cgraph_varpool_node (tree);
212 struct cgraph_varpool_node *cgraph_varpool_node_for_asm (tree asmname);
213 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
214 void cgraph_varpool_finalize_decl (tree);
215 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
217 bool cgraph_function_possibly_inlined_p (tree);
218 void cgraph_unnest_node (struct cgraph_node *);
219 void cgraph_varpool_enqueue_needed_node (struct cgraph_varpool_node *);
220 void cgraph_varpool_reset_queue (void);
221 bool decide_is_variable_needed (struct cgraph_varpool_node *, tree);
223 /* In cgraphunit.c */
224 bool cgraph_assemble_pending_functions (void);
225 bool cgraph_varpool_assemble_pending_decls (void);
226 void cgraph_finalize_function (tree, bool);
227 void cgraph_lower_function (struct cgraph_node *);
228 void cgraph_finalize_compilation_unit (void);
229 void cgraph_optimize (void);
230 void cgraph_mark_needed_node (struct cgraph_node *);
231 void cgraph_mark_reachable_node (struct cgraph_node *);
232 bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
233 bool cgraph_preserve_function_body_p (tree);
234 void verify_cgraph (void);
235 void verify_cgraph_node (struct cgraph_node *);
236 void cgraph_mark_inline_edge (struct cgraph_edge *e);
237 void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate);
238 void cgraph_build_static_cdtor (char which, tree body, int priority);
239 void cgraph_reset_static_var_maps (void);
240 void init_cgraph (void);
242 /* In ipa.c */
243 bool cgraph_remove_unreachable_nodes (bool, FILE *);
244 int cgraph_postorder (struct cgraph_node **);
246 /* In ipa-inline.c */
247 void cgraph_decide_inlining_incrementally (struct cgraph_node *);
248 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool);
249 void cgraph_mark_inline_edge (struct cgraph_edge *);
250 bool cgraph_default_inline_p (struct cgraph_node *);
251 #endif /* GCC_CGRAPH_H */