OSDN Git Service

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