]>
Commit | Line | Data |
---|---|---|
1c4a429a | 1 | /* Callgraph handling code. |
d9221e01 | 2 | Copyright (C) 2003, 2004 Free Software Foundation, Inc. |
1c4a429a JH |
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 | ||
dafc5b82 | 25 | /* Information about the function collected locally. |
25c84396 | 26 | Available after function is analyzed. */ |
dafc5b82 | 27 | |
ed2df68b | 28 | struct cgraph_local_info GTY(()) |
dafc5b82 | 29 | { |
95c755e9 JH |
30 | /* Size of the function before inlining. */ |
31 | int self_insns; | |
32 | ||
e0bb17a8 | 33 | /* Set when function function is visible in current compilation unit only |
dafc5b82 JH |
34 | and it's address is never taken. */ |
35 | bool local; | |
f6981e16 JH |
36 | /* Set once it has been finalized so we consider it to be output. */ |
37 | bool finalized; | |
b58b1157 | 38 | |
b3c3af2f | 39 | /* False when there something makes inlining impossible (such as va_arg). */ |
b58b1157 JH |
40 | bool inlinable; |
41 | /* True when function should be inlined independently on it's size. */ | |
b3c3af2f | 42 | bool disregard_inline_limits; |
95c755e9 JH |
43 | /* True when the function has been originally extern inline, but it is |
44 | redefined now. */ | |
45 | bool redefined_extern_inline; | |
dafc5b82 JH |
46 | }; |
47 | ||
48 | /* Information about the function that needs to be computed globally | |
49 | once compilation is finished. Available only with -funit-at-time. */ | |
50 | ||
ed2df68b | 51 | struct cgraph_global_info GTY(()) |
dafc5b82 | 52 | { |
b58b1157 JH |
53 | /* Estimated size of the function after inlining. */ |
54 | int insns; | |
55 | ||
b58b1157 JH |
56 | /* Number of times given function will be cloned during output. */ |
57 | int cloned_times; | |
58 | ||
95c755e9 JH |
59 | /* Set when the function will be inlined exactly once. */ |
60 | bool inline_once; | |
61 | ||
b58b1157 JH |
62 | /* Set to true for all reachable functions before inlining is decided. |
63 | Once we inline all calls to the function and the function is local, | |
64 | it is set to false. */ | |
65 | bool will_be_output; | |
1bb17c21 JH |
66 | |
67 | /* Set iff at least one of the caller edges has inline_call flag set. */ | |
68 | bool inlined; | |
dafc5b82 JH |
69 | }; |
70 | ||
b255a036 JH |
71 | /* Information about the function that is propagated by the RTL backend. |
72 | Available only for functions that has been already assembled. */ | |
73 | ||
ed2df68b | 74 | struct cgraph_rtl_info GTY(()) |
b255a036 | 75 | { |
ed2df68b JH |
76 | bool const_function; |
77 | bool pure_function; | |
b255a036 JH |
78 | int preferred_incoming_stack_boundary; |
79 | }; | |
80 | ||
dafc5b82 | 81 | |
ba228239 | 82 | /* The cgraph data structure. |
e0bb17a8 | 83 | Each function decl has assigned cgraph_node listing callees and callers. */ |
1c4a429a | 84 | |
d1bd0ded | 85 | struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) |
1c4a429a JH |
86 | { |
87 | tree decl; | |
88 | struct cgraph_edge *callees; | |
89 | struct cgraph_edge *callers; | |
ed2df68b JH |
90 | struct cgraph_node *next; |
91 | struct cgraph_node *previous; | |
1c4a429a JH |
92 | /* For nested functions points to function the node is nested in. */ |
93 | struct cgraph_node *origin; | |
94 | /* Points to first nested function, if any. */ | |
95 | struct cgraph_node *nested; | |
96 | /* Pointer to the next function with same origin, if any. */ | |
97 | struct cgraph_node *next_nested; | |
8bd87c4e JH |
98 | /* Pointer to the next function in cgraph_nodes_queue. */ |
99 | struct cgraph_node *next_needed; | |
1431042e | 100 | PTR GTY ((skip)) aux; |
1c4a429a | 101 | |
95c755e9 JH |
102 | struct cgraph_local_info local; |
103 | struct cgraph_global_info global; | |
104 | struct cgraph_rtl_info rtl; | |
105 | /* Unique id of the node. */ | |
106 | int uid; | |
1c4a429a JH |
107 | /* Set when function must be output - it is externally visible |
108 | or it's address is taken. */ | |
109 | bool needed; | |
110 | /* Set when function is reachable by call from other function | |
e0bb17a8 | 111 | that is either reachable or needed. */ |
1c4a429a | 112 | bool reachable; |
25c84396 RH |
113 | /* Set once the function has been instantiated and its callee |
114 | lists created. */ | |
115 | bool analyzed; | |
1c4a429a JH |
116 | /* Set when function is scheduled to be assembled. */ |
117 | bool output; | |
118 | }; | |
119 | ||
ed2df68b | 120 | struct cgraph_edge GTY(()) |
1c4a429a | 121 | { |
ed2df68b JH |
122 | struct cgraph_node *caller; |
123 | struct cgraph_node *callee; | |
1c4a429a JH |
124 | struct cgraph_edge *next_caller; |
125 | struct cgraph_edge *next_callee; | |
dc0bfe6a JH |
126 | /* When NULL, inline this call. When non-NULL, points to the explanation |
127 | why function was not inlined. */ | |
128 | const char *inline_failed; | |
1c4a429a JH |
129 | }; |
130 | ||
ba228239 | 131 | /* The cgraph_varpool data structure. |
e69529cd JH |
132 | Each static variable decl has assigned cgraph_varpool_node. */ |
133 | ||
ed2df68b | 134 | struct cgraph_varpool_node GTY(()) |
e69529cd JH |
135 | { |
136 | tree decl; | |
8bd87c4e JH |
137 | /* Pointer to the next function in cgraph_varpool_nodes_queue. */ |
138 | struct cgraph_varpool_node *next_needed; | |
e69529cd JH |
139 | |
140 | /* Set when function must be output - it is externally visible | |
141 | or it's address is taken. */ | |
142 | bool needed; | |
143 | /* Set once it has been finalized so we consider it to be output. */ | |
144 | bool finalized; | |
145 | /* Set when function is scheduled to be assembled. */ | |
146 | bool output; | |
147 | }; | |
148 | ||
ed2df68b JH |
149 | extern GTY(()) struct cgraph_node *cgraph_nodes; |
150 | extern GTY(()) int cgraph_n_nodes; | |
b58b1157 | 151 | extern GTY(()) int cgraph_max_uid; |
dafc5b82 | 152 | extern bool cgraph_global_info_ready; |
ed2df68b | 153 | extern GTY(()) struct cgraph_node *cgraph_nodes_queue; |
a194aa56 | 154 | extern FILE *cgraph_dump_file; |
1c4a429a | 155 | |
ed2df68b JH |
156 | extern GTY(()) int cgraph_varpool_n_nodes; |
157 | extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue; | |
e69529cd JH |
158 | |
159 | ||
1c4a429a | 160 | /* In cgraph.c */ |
439f7bc3 | 161 | void dump_cgraph (FILE *); |
cb967da5 | 162 | void cgraph_remove_edge (struct cgraph_node *, struct cgraph_node *); |
439f7bc3 AJ |
163 | void cgraph_remove_call (tree, tree); |
164 | void cgraph_remove_node (struct cgraph_node *); | |
165 | struct cgraph_edge *cgraph_record_call (tree, tree); | |
166 | struct cgraph_node *cgraph_node (tree decl); | |
167 | struct cgraph_node *cgraph_node_for_identifier (tree id); | |
168 | bool cgraph_calls_p (tree, tree); | |
169 | struct cgraph_local_info *cgraph_local_info (tree); | |
170 | struct cgraph_global_info *cgraph_global_info (tree); | |
171 | struct cgraph_rtl_info *cgraph_rtl_info (tree); | |
172 | const char * cgraph_node_name (struct cgraph_node *); | |
1c4a429a | 173 | |
e69529cd JH |
174 | struct cgraph_varpool_node *cgraph_varpool_node (tree decl); |
175 | struct cgraph_varpool_node *cgraph_varpool_node_for_identifier (tree id); | |
176 | void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *); | |
177 | void cgraph_varpool_finalize_decl (tree); | |
178 | bool cgraph_varpool_assemble_pending_decls (void); | |
179 | ||
1bb17c21 JH |
180 | bool cgraph_function_possibly_inlined_p (tree); |
181 | ||
1c4a429a | 182 | /* In cgraphunit.c */ |
f6d1b84a | 183 | bool cgraph_assemble_pending_functions (void); |
6b00c969 | 184 | void cgraph_finalize_function (tree, bool); |
439f7bc3 AJ |
185 | void cgraph_finalize_compilation_unit (void); |
186 | void cgraph_create_edges (tree, tree); | |
187 | void cgraph_optimize (void); | |
8dafba3c RH |
188 | void cgraph_mark_needed_node (struct cgraph_node *); |
189 | void cgraph_mark_reachable_node (struct cgraph_node *); | |
dc0bfe6a | 190 | bool cgraph_inline_p (tree, tree, const char **reason); |
1c4a429a JH |
191 | |
192 | #endif /* GCC_CGRAPH_H */ |