Daily bump.
[gcc.git] / gcc / cgraph.h
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004 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 it's 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 it's 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
56 /* Information about the function that needs to be computed globally
57 once compilation is finished. Available only with -funit-at-time. */
58
59 struct cgraph_global_info GTY(())
60 {
61 /* For inline clones this points to the function they will be inlined into. */
62 struct cgraph_node *inlined_to;
63
64 /* Estimated size of the function after inlining. */
65 int insns;
66
67 /* Set iff the function has been inlined at least once. */
68 bool inlined;
69 };
70
71 /* Information about the function that is propagated by the RTL backend.
72 Available only for functions that has been already assembled. */
73
74 struct cgraph_rtl_info GTY(())
75 {
76 int preferred_incoming_stack_boundary;
77 bool const_function;
78 bool pure_function;
79 };
80
81 /* The cgraph data structure.
82 Each function decl has assigned cgraph_node listing callees and callers. */
83
84 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
85 {
86 tree decl;
87 struct cgraph_edge *callees;
88 struct cgraph_edge *callers;
89 struct cgraph_node *next;
90 struct cgraph_node *previous;
91 /* For nested functions points to function the node is nested in. */
92 struct cgraph_node *origin;
93 /* Points to first nested function, if any. */
94 struct cgraph_node *nested;
95 /* Pointer to the next function with same origin, if any. */
96 struct cgraph_node *next_nested;
97 /* Pointer to the next function in cgraph_nodes_queue. */
98 struct cgraph_node *next_needed;
99 /* Pointer to the next clone. */
100 struct cgraph_node *next_clone;
101 PTR GTY ((skip)) aux;
102
103 struct cgraph_local_info local;
104 struct cgraph_global_info global;
105 struct cgraph_rtl_info rtl;
106
107 /* Unique id of the node. */
108 int uid;
109 /* Set when function must be output - it is externally visible
110 or it's address is taken. */
111 bool needed;
112 /* Set when function is reachable by call from other function
113 that is either reachable or needed. */
114 bool reachable;
115 /* Set once the function has been instantiated and its callee
116 lists created. */
117 bool analyzed;
118 /* Set when function is scheduled to be assembled. */
119 bool output;
120 };
121
122 struct cgraph_edge GTY((chain_next ("%h.next_caller")))
123 {
124 struct cgraph_node *caller;
125 struct cgraph_node *callee;
126 struct cgraph_edge *next_caller;
127 struct cgraph_edge *next_callee;
128 tree call_expr;
129 PTR GTY ((skip (""))) aux;
130 /* When NULL, inline this call. When non-NULL, points to the explanation
131 why function was not inlined. */
132 const char *inline_failed;
133 };
134
135 /* The cgraph_varpool data structure.
136 Each static variable decl has assigned cgraph_varpool_node. */
137
138 struct cgraph_varpool_node GTY(())
139 {
140 tree decl;
141 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
142 struct cgraph_varpool_node *next_needed;
143
144 /* Set when function must be output - it is externally visible
145 or it's address is taken. */
146 bool needed;
147 /* Set once it has been finalized so we consider it to be output. */
148 bool finalized;
149 /* Set when function is scheduled to be assembled. */
150 bool output;
151 };
152
153 extern GTY(()) struct cgraph_node *cgraph_nodes;
154 extern GTY(()) int cgraph_n_nodes;
155 extern GTY(()) int cgraph_max_uid;
156 extern bool cgraph_global_info_ready;
157 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
158
159 extern GTY(()) int cgraph_varpool_n_nodes;
160 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
161
162 /* In cgraph.c */
163 void dump_cgraph (FILE *);
164 void dump_cgraph_node (FILE *, struct cgraph_node *);
165 void cgraph_remove_edge (struct cgraph_edge *);
166 void cgraph_remove_node (struct cgraph_node *);
167 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
168 struct cgraph_node *,
169 tree);
170 struct cgraph_node *cgraph_node (tree decl);
171 struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree call_expr);
172 bool cgraph_calls_p (tree, tree);
173 struct cgraph_local_info *cgraph_local_info (tree);
174 struct cgraph_global_info *cgraph_global_info (tree);
175 struct cgraph_rtl_info *cgraph_rtl_info (tree);
176 const char * cgraph_node_name (struct cgraph_node *);
177 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, struct cgraph_node *, tree);
178 struct cgraph_node * cgraph_clone_node (struct cgraph_node *);
179
180 struct cgraph_varpool_node *cgraph_varpool_node (tree decl);
181 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
182 void cgraph_varpool_finalize_decl (tree);
183 bool cgraph_varpool_assemble_pending_decls (void);
184 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
185
186 bool cgraph_function_possibly_inlined_p (tree);
187 void cgraph_unnest_node (struct cgraph_node *node);
188
189 /* In cgraphunit.c */
190 bool cgraph_assemble_pending_functions (void);
191 void cgraph_finalize_function (tree, bool);
192 void cgraph_finalize_compilation_unit (void);
193 void cgraph_create_edges (struct cgraph_node *, tree);
194 void cgraph_optimize (void);
195 void cgraph_mark_needed_node (struct cgraph_node *);
196 void cgraph_mark_reachable_node (struct cgraph_node *);
197 bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
198 bool cgraph_preserve_function_body_p (tree);
199 void verify_cgraph (void);
200 void verify_cgraph_node (struct cgraph_node *);
201 void cgraph_mark_inline_edge (struct cgraph_edge *e);
202 void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate);
203 void cgraph_build_static_cdtor (char which, tree body, int priority);
204 void cgraph_reset_static_var_maps (void);
205 void init_cgraph (void);
206
207 #endif /* GCC_CGRAPH_H */