* cgraph.c: Add overall comment.
[official-gcc.git] / gcc / cgraph.h
blob617861be1ce5dce2ab058bfb5c0e04d12d4d3e9b
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004 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 "hashtab.h"
26 /* Information about the function collected locally.
27 Available after function is analyzed. */
29 struct cgraph_local_info GTY(())
31 /* Size of the function before inlining. */
32 int self_insns;
34 /* Set when function function is visible in current compilation unit only
35 and it's address is never taken. */
36 bool local;
37 /* Set once it has been finalized so we consider it to be output. */
38 bool finalized;
40 /* False when there something makes inlining impossible (such as va_arg). */
41 bool inlinable;
42 /* True when function should be inlined independently on it's size. */
43 bool disregard_inline_limits;
44 /* True when the function has been originally extern inline, but it is
45 redefined now. */
46 bool redefined_extern_inline;
49 /* Information about the function that needs to be computed globally
50 once compilation is finished. Available only with -funit-at-time. */
52 struct cgraph_global_info GTY(())
54 /* For inline clones this points to the function they will be inlined into. */
55 struct cgraph_node *inlined_to;
57 /* Estimated size of the function after inlining. */
58 int insns;
60 /* Set iff the function has been inlined at least once. */
61 bool inlined;
64 /* Information about the function that is propagated by the RTL backend.
65 Available only for functions that has been already assembled. */
67 struct cgraph_rtl_info GTY(())
69 bool const_function;
70 bool pure_function;
71 int preferred_incoming_stack_boundary;
75 /* The cgraph data structure.
76 Each function decl has assigned cgraph_node listing callees and callers. */
78 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
80 tree decl;
81 struct cgraph_edge *callees;
82 struct cgraph_edge *callers;
83 struct cgraph_node *next;
84 struct cgraph_node *previous;
85 /* For nested functions points to function the node is nested in. */
86 struct cgraph_node *origin;
87 /* Points to first nested function, if any. */
88 struct cgraph_node *nested;
89 /* Pointer to the next function with same origin, if any. */
90 struct cgraph_node *next_nested;
91 /* Pointer to the next function in cgraph_nodes_queue. */
92 struct cgraph_node *next_needed;
93 /* Pointer to the next clone. */
94 struct cgraph_node *next_clone;
95 PTR GTY ((skip)) aux;
97 struct cgraph_local_info local;
98 struct cgraph_global_info global;
99 struct cgraph_rtl_info rtl;
100 /* Unique id of the node. */
101 int uid;
102 /* Set when function must be output - it is externally visible
103 or it's address is taken. */
104 bool needed;
105 /* Set when function is reachable by call from other function
106 that is either reachable or needed. */
107 bool reachable;
108 /* Set once the function has been instantiated and its callee
109 lists created. */
110 bool analyzed;
111 /* Set when function is scheduled to be assembled. */
112 bool output;
115 struct cgraph_edge GTY((chain_next ("%h.next_caller")))
117 struct cgraph_node *caller;
118 struct cgraph_node *callee;
119 struct cgraph_edge *next_caller;
120 struct cgraph_edge *next_callee;
121 tree call_expr;
122 PTR GTY ((skip (""))) aux;
123 /* When NULL, inline this call. When non-NULL, points to the explanation
124 why function was not inlined. */
125 const char *inline_failed;
128 /* The cgraph_varpool data structure.
129 Each static variable decl has assigned cgraph_varpool_node. */
131 struct cgraph_varpool_node GTY(())
133 tree decl;
134 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
135 struct cgraph_varpool_node *next_needed;
137 /* Set when function must be output - it is externally visible
138 or it's address is taken. */
139 bool needed;
140 /* Set once it has been finalized so we consider it to be output. */
141 bool finalized;
142 /* Set when function is scheduled to be assembled. */
143 bool output;
146 extern GTY(()) struct cgraph_node *cgraph_nodes;
147 extern GTY(()) int cgraph_n_nodes;
148 extern GTY(()) int cgraph_max_uid;
149 extern bool cgraph_global_info_ready;
150 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
151 extern FILE *cgraph_dump_file;
153 extern GTY(()) int cgraph_varpool_n_nodes;
154 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
155 extern GTY((param_is (union tree_node))) htab_t cgraph_inline_hash;
158 /* In cgraph.c */
159 void dump_cgraph (FILE *);
160 void dump_cgraph_node (FILE *, struct cgraph_node *);
161 void cgraph_remove_edge (struct cgraph_edge *);
162 void cgraph_remove_node (struct cgraph_node *);
163 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
164 struct cgraph_node *,
165 tree);
166 struct cgraph_node *cgraph_node (tree decl);
167 struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree call_expr);
168 struct cgraph_node *cgraph_node_for_identifier (tree id);
169 bool cgraph_calls_p (tree, tree);
170 struct cgraph_local_info *cgraph_local_info (tree);
171 struct cgraph_global_info *cgraph_global_info (tree);
172 struct cgraph_rtl_info *cgraph_rtl_info (tree);
173 const char * cgraph_node_name (struct cgraph_node *);
174 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, struct cgraph_node *, tree);
175 struct cgraph_node * cgraph_clone_node (struct cgraph_node *);
177 struct cgraph_varpool_node *cgraph_varpool_node (tree decl);
178 struct cgraph_varpool_node *cgraph_varpool_node_for_identifier (tree id);
179 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
180 void cgraph_varpool_finalize_decl (tree);
181 bool cgraph_varpool_assemble_pending_decls (void);
182 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
184 bool cgraph_function_possibly_inlined_p (tree);
186 /* In cgraphunit.c */
187 bool cgraph_assemble_pending_functions (void);
188 void cgraph_finalize_function (tree, bool);
189 void cgraph_finalize_compilation_unit (void);
190 void cgraph_create_edges (struct cgraph_node *, tree);
191 void cgraph_optimize (void);
192 void cgraph_mark_needed_node (struct cgraph_node *);
193 void cgraph_mark_reachable_node (struct cgraph_node *);
194 bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
195 bool cgraph_preserve_function_body_p (tree);
196 void verify_cgraph (void);
197 void verify_cgraph_node (struct cgraph_node *);
198 void cgraph_mark_inline_edge (struct cgraph_edge *e);
199 void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate);
201 #endif /* GCC_CGRAPH_H */