OSDN Git Service

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