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