OSDN Git Service

* cgraph.c (cgraph_max_uid): New global variable.
[pf3gnuchains/gcc-fork.git] / gcc / cgraph.h
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
25 /* Information about the function collected locally.
26    Available after function is lowered  */
27
28 struct cgraph_local_info GTY(())
29 {
30   /* Set when function function is visible in current compilation unit only
31      and it's address is never taken.  */
32   bool local;
33   /* Set once it has been finalized so we consider it to be output.  */
34   bool finalized;
35
36   /* False when there is something making inlining impossible (such as va_arg) */
37   bool inlinable;
38   /* True when function should be inlined independently on it's size.  */
39   bool disgread_inline_limits;
40   /* Size of the function before inlining.  */
41   int self_insns;
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
47 struct cgraph_global_info GTY(())
48 {
49   /* Set when the function will be inlined exactly once.  */
50   bool inline_once;
51
52   /* Estimated size of the function after inlining.  */
53   int insns;
54
55   /* Number of direct calls not inlined into the function body.  */
56   int calls;
57
58   /* Number of times given function will be cloned during output.  */
59   int cloned_times;
60
61   /* Set to true for all reachable functions before inlining is decided.
62      Once we inline all calls to the function and the function is local,
63      it is set to false.  */
64   bool will_be_output;
65 };
66
67 /* Information about the function that is propagated by the RTL backend.
68    Available only for functions that has been already assembled.  */
69
70 struct cgraph_rtl_info GTY(())
71 {
72    bool const_function;
73    bool pure_function;
74    int preferred_incoming_stack_boundary;
75 };
76
77
78 /* The cgraph data strutcture.
79    Each function decl has assigned cgraph_node listing callees and callers.  */
80
81 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
82 {
83   tree decl;
84   struct cgraph_edge *callees;
85   struct cgraph_edge *callers;
86   struct cgraph_node *next;
87   struct cgraph_node *previous;
88   /* For nested functions points to function the node is nested in.  */
89   struct cgraph_node *origin;
90   /* Points to first nested function, if any.  */
91   struct cgraph_node *nested;
92   /* Pointer to the next function with same origin, if any.  */
93   struct cgraph_node *next_nested;
94   /* Pointer to the next function in cgraph_nodes_queue.  */
95   struct cgraph_node *next_needed;
96   /* Unique id of the node.  */
97   int uid;
98   PTR GTY ((skip (""))) aux;
99
100   /* Set when function must be output - it is externally visible
101      or it's address is taken.  */
102   bool needed;
103   /* Set when function is reachable by call from other function
104      that is either reachable or needed.  */
105   bool reachable;
106   /* Set when the frontend has been asked to lower representation of this
107      function into trees.  Callees lists are not available when lowered
108      is not set.  */
109   bool lowered;
110   /* Set when function is scheduled to be assembled.  */
111   bool output;
112   struct cgraph_local_info local;
113   struct cgraph_global_info global;
114   struct cgraph_rtl_info rtl;
115 };
116
117 struct cgraph_edge GTY(())
118 {
119   struct cgraph_node *caller;
120   struct cgraph_node *callee;
121   struct cgraph_edge *next_caller;
122   struct cgraph_edge *next_callee;
123   bool inline_call;
124 };
125
126 /* The cgraph_varpool data strutcture.
127    Each static variable decl has assigned cgraph_varpool_node.  */
128
129 struct cgraph_varpool_node GTY(())
130 {
131   tree decl;
132   /* Pointer to the next function in cgraph_varpool_nodes_queue.  */
133   struct cgraph_varpool_node *next_needed;
134
135   /* Set when function must be output - it is externally visible
136      or it's address is taken.  */
137   bool needed;
138   /* Set once it has been finalized so we consider it to be output.  */
139   bool finalized;
140   /* Set when function is scheduled to be assembled.  */
141   bool output;
142 };
143
144 extern GTY(()) struct cgraph_node *cgraph_nodes;
145 extern GTY(()) int cgraph_n_nodes;
146 extern GTY(()) int cgraph_max_uid;
147 extern bool cgraph_global_info_ready;
148 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
149 extern FILE *cgraph_dump_file;
150
151 extern GTY(()) int cgraph_varpool_n_nodes;
152 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
153
154
155 /* In cgraph.c  */
156 void dump_cgraph                        PARAMS ((FILE *));
157 void cgraph_remove_call                 PARAMS ((tree, tree));
158 void cgraph_remove_node                 PARAMS ((struct cgraph_node *));
159 struct cgraph_edge *cgraph_record_call  PARAMS ((tree, tree));
160 struct cgraph_node *cgraph_node         PARAMS ((tree decl));
161 struct cgraph_node *cgraph_node_for_identifier  PARAMS ((tree id));
162 bool cgraph_calls_p                     PARAMS ((tree, tree));
163 struct cgraph_local_info *cgraph_local_info PARAMS ((tree));
164 struct cgraph_global_info *cgraph_global_info PARAMS ((tree));
165 struct cgraph_rtl_info *cgraph_rtl_info PARAMS ((tree));
166 const char * cgraph_node_name PARAMS ((struct cgraph_node *));
167
168 struct cgraph_varpool_node *cgraph_varpool_node (tree decl);
169 struct cgraph_varpool_node *cgraph_varpool_node_for_identifier (tree id);
170 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
171 void cgraph_varpool_finalize_decl (tree);
172 bool cgraph_varpool_assemble_pending_decls (void);
173
174 /* In cgraphunit.c  */
175 void cgraph_finalize_function           PARAMS ((tree, tree));
176 void cgraph_finalize_compilation_unit   PARAMS ((void));
177 void cgraph_create_edges                PARAMS ((tree, tree));
178 void cgraph_optimize                    PARAMS ((void));
179 void cgraph_mark_needed_node            PARAMS ((struct cgraph_node *, int));
180 bool cgraph_inline_p                    PARAMS ((tree, tree));
181
182 #endif  /* GCC_CGRAPH_H  */