]>
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 JH |
25 | /* Information about the function collected locally. |
26 | Available after function is lowered */ | |
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; | |
e0bb17a8 | 33 | /* Set when function is small enough to be inlinable many times. */ |
dafc5b82 | 34 | bool inline_many; |
18d13f34 JH |
35 | /* Set when function can be inlined once (false only for functions calling |
36 | alloca, using varargs and so on). */ | |
37 | bool can_inline_once; | |
f6981e16 JH |
38 | /* Set once it has been finalized so we consider it to be output. */ |
39 | bool finalized; | |
dafc5b82 JH |
40 | }; |
41 | ||
42 | /* Information about the function that needs to be computed globally | |
43 | once compilation is finished. Available only with -funit-at-time. */ | |
44 | ||
ed2df68b | 45 | struct cgraph_global_info GTY(()) |
dafc5b82 | 46 | { |
18d13f34 JH |
47 | /* Set when the function will be inlined exactly once. */ |
48 | bool inline_once; | |
dafc5b82 JH |
49 | }; |
50 | ||
b255a036 JH |
51 | /* Information about the function that is propagated by the RTL backend. |
52 | Available only for functions that has been already assembled. */ | |
53 | ||
ed2df68b | 54 | struct cgraph_rtl_info GTY(()) |
b255a036 | 55 | { |
ed2df68b JH |
56 | bool const_function; |
57 | bool pure_function; | |
b255a036 JH |
58 | int preferred_incoming_stack_boundary; |
59 | }; | |
60 | ||
dafc5b82 | 61 | |
1c4a429a | 62 | /* The cgraph data strutcture. |
e0bb17a8 | 63 | Each function decl has assigned cgraph_node listing callees and callers. */ |
1c4a429a | 64 | |
ed2df68b | 65 | struct cgraph_node GTY(()) |
1c4a429a JH |
66 | { |
67 | tree decl; | |
68 | struct cgraph_edge *callees; | |
69 | struct cgraph_edge *callers; | |
ed2df68b JH |
70 | struct cgraph_node *next; |
71 | struct cgraph_node *previous; | |
1c4a429a JH |
72 | /* For nested functions points to function the node is nested in. */ |
73 | struct cgraph_node *origin; | |
74 | /* Points to first nested function, if any. */ | |
75 | struct cgraph_node *nested; | |
76 | /* Pointer to the next function with same origin, if any. */ | |
77 | struct cgraph_node *next_nested; | |
8bd87c4e JH |
78 | /* Pointer to the next function in cgraph_nodes_queue. */ |
79 | struct cgraph_node *next_needed; | |
ed2df68b | 80 | PTR GTY ((skip (""))) aux; |
1c4a429a JH |
81 | |
82 | /* Set when function must be output - it is externally visible | |
83 | or it's address is taken. */ | |
84 | bool needed; | |
85 | /* Set when function is reachable by call from other function | |
e0bb17a8 | 86 | that is either reachable or needed. */ |
1c4a429a JH |
87 | bool reachable; |
88 | /* Set when the frontend has been asked to lower representation of this | |
89 | function into trees. Callees lists are not available when lowered | |
90 | is not set. */ | |
91 | bool lowered; | |
92 | /* Set when function is scheduled to be assembled. */ | |
93 | bool output; | |
dafc5b82 JH |
94 | struct cgraph_local_info local; |
95 | struct cgraph_global_info global; | |
b255a036 | 96 | struct cgraph_rtl_info rtl; |
1c4a429a JH |
97 | }; |
98 | ||
ed2df68b | 99 | struct cgraph_edge GTY(()) |
1c4a429a | 100 | { |
ed2df68b JH |
101 | struct cgraph_node *caller; |
102 | struct cgraph_node *callee; | |
1c4a429a JH |
103 | struct cgraph_edge *next_caller; |
104 | struct cgraph_edge *next_callee; | |
105 | }; | |
106 | ||
e69529cd JH |
107 | /* The cgraph_varpool data strutcture. |
108 | Each static variable decl has assigned cgraph_varpool_node. */ | |
109 | ||
ed2df68b | 110 | struct cgraph_varpool_node GTY(()) |
e69529cd JH |
111 | { |
112 | tree decl; | |
8bd87c4e JH |
113 | /* Pointer to the next function in cgraph_varpool_nodes_queue. */ |
114 | struct cgraph_varpool_node *next_needed; | |
e69529cd JH |
115 | |
116 | /* Set when function must be output - it is externally visible | |
117 | or it's address is taken. */ | |
118 | bool needed; | |
119 | /* Set once it has been finalized so we consider it to be output. */ | |
120 | bool finalized; | |
121 | /* Set when function is scheduled to be assembled. */ | |
122 | bool output; | |
123 | }; | |
124 | ||
ed2df68b JH |
125 | extern GTY(()) struct cgraph_node *cgraph_nodes; |
126 | extern GTY(()) int cgraph_n_nodes; | |
dafc5b82 | 127 | extern bool cgraph_global_info_ready; |
ed2df68b | 128 | extern GTY(()) struct cgraph_node *cgraph_nodes_queue; |
a194aa56 | 129 | extern FILE *cgraph_dump_file; |
1c4a429a | 130 | |
ed2df68b JH |
131 | extern GTY(()) int cgraph_varpool_n_nodes; |
132 | extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue; | |
e69529cd JH |
133 | |
134 | ||
1c4a429a JH |
135 | /* In cgraph.c */ |
136 | void dump_cgraph PARAMS ((FILE *)); | |
137 | void cgraph_remove_call PARAMS ((tree, tree)); | |
18d13f34 | 138 | void cgraph_remove_node PARAMS ((struct cgraph_node *)); |
1c4a429a JH |
139 | struct cgraph_edge *cgraph_record_call PARAMS ((tree, tree)); |
140 | struct cgraph_node *cgraph_node PARAMS ((tree decl)); | |
1668aabc | 141 | struct cgraph_node *cgraph_node_for_identifier PARAMS ((tree id)); |
1c4a429a | 142 | bool cgraph_calls_p PARAMS ((tree, tree)); |
dafc5b82 JH |
143 | struct cgraph_local_info *cgraph_local_info PARAMS ((tree)); |
144 | struct cgraph_global_info *cgraph_global_info PARAMS ((tree)); | |
b255a036 | 145 | struct cgraph_rtl_info *cgraph_rtl_info PARAMS ((tree)); |
a194aa56 | 146 | const char * cgraph_node_name PARAMS ((struct cgraph_node *)); |
1c4a429a | 147 | |
e69529cd JH |
148 | struct cgraph_varpool_node *cgraph_varpool_node (tree decl); |
149 | struct cgraph_varpool_node *cgraph_varpool_node_for_identifier (tree id); | |
150 | void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *); | |
151 | void cgraph_varpool_finalize_decl (tree); | |
152 | bool cgraph_varpool_assemble_pending_decls (void); | |
153 | ||
1c4a429a JH |
154 | /* In cgraphunit.c */ |
155 | void cgraph_finalize_function PARAMS ((tree, tree)); | |
156 | void cgraph_finalize_compilation_unit PARAMS ((void)); | |
157 | void cgraph_create_edges PARAMS ((tree, tree)); | |
158 | void cgraph_optimize PARAMS ((void)); | |
159 | void cgraph_mark_needed_node PARAMS ((struct cgraph_node *, int)); | |
160 | ||
161 | #endif /* GCC_CGRAPH_H */ |