OSDN Git Service

016ce9de14c9b6437c623a8b0f9a31aed3419bd9
[pf3gnuchains/gcc-fork.git] / gcc / cgraph.h
1 /* Callgraph handling code.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
3    Free Software Foundation, Inc.
4    Contributed by Jan Hubicka
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H
24 #include "tree.h"
25 #include "basic-block.h"
26
27 enum availability
28 {
29   /* Not yet set by cgraph_function_body_availability.  */
30   AVAIL_UNSET,
31   /* Function body/variable initializer is unknown.  */
32   AVAIL_NOT_AVAILABLE,
33   /* Function body/variable initializer is known but might be replaced
34      by a different one from other compilation unit and thus needs to
35      be dealt with a care.  Like AVAIL_NOT_AVAILABLE it can have
36      arbitrary side effects on escaping variables and functions, while
37      like AVAILABLE it might access static variables.  */
38   AVAIL_OVERWRITABLE,
39   /* Function body/variable initializer is known and will be used in final
40      program.  */
41   AVAIL_AVAILABLE,
42   /* Function body/variable initializer is known and all it's uses are explicitly
43      visible within current unit (ie it's address is never taken and it is not
44      exported to other units).
45      Currently used only for functions.  */
46   AVAIL_LOCAL
47 };
48
49 /* This is the information that is put into the cgraph local structure
50    to recover a function.  */
51 struct lto_file_decl_data;
52
53 extern const char * const cgraph_availability_names[];
54
55 /* Function inlining information.  */
56
57 struct GTY(()) inline_summary
58 {
59   /* Estimated stack frame consumption by the function.  */
60   HOST_WIDE_INT estimated_self_stack_size;
61
62   /* Size of the function body.  */
63   int self_size;
64   /* How many instructions are likely going to disappear after inlining.  */
65   int size_inlining_benefit;
66   /* Estimated time spent executing the function body.  */
67   int self_time;
68   /* How much time is going to be saved by inlining.  */
69   int time_inlining_benefit;
70 };
71
72 /* Information about the function collected locally.
73    Available after function is analyzed.  */
74
75 struct GTY(()) cgraph_local_info {
76   /* File stream where this node is being written to.  */
77   struct lto_file_decl_data * GTY ((skip)) lto_file_data;
78
79   struct inline_summary inline_summary;
80
81   /* Set when function function is visible in current compilation unit only
82      and its address is never taken.  */
83   unsigned local : 1;
84
85   /* Set when function is visible by other units.  */
86   unsigned externally_visible : 1;
87
88   /* Set once it has been finalized so we consider it to be output.  */
89   unsigned finalized : 1;
90
91   /* False when there something makes inlining impossible (such as va_arg).  */
92   unsigned inlinable : 1;
93
94   /* True when function should be inlined independently on its size.  */
95   unsigned disregard_inline_limits : 1;
96
97   /* True when the function has been originally extern inline, but it is
98      redefined now.  */
99   unsigned redefined_extern_inline : 1;
100
101   /* True if statics_read_for_function and
102      statics_written_for_function contain valid data.  */
103   unsigned for_functions_valid : 1;
104
105   /* True if the function is going to be emitted in some other translation
106      unit, referenced from vtable.  */
107   unsigned vtable_method : 1;
108 };
109
110 /* Information about the function that needs to be computed globally
111    once compilation is finished.  Available only with -funit-at-a-time.  */
112
113 struct GTY(()) cgraph_global_info {
114   /* Estimated stack frame consumption by the function.  */
115   HOST_WIDE_INT estimated_stack_size;
116   /* Expected offset of the stack frame of inlined function.  */
117   HOST_WIDE_INT stack_frame_offset;
118
119   /* For inline clones this points to the function they will be
120      inlined into.  */
121   struct cgraph_node *inlined_to;
122
123   /* Estimated size of the function after inlining.  */
124   int time;
125   int size;
126
127   /* Estimated growth after inlining.  INT_MIN if not computed.  */
128   int estimated_growth;
129
130   /* Set iff the function has been inlined at least once.  */
131   bool inlined;
132 };
133
134 /* Information about the function that is propagated by the RTL backend.
135    Available only for functions that has been already assembled.  */
136
137 struct GTY(()) cgraph_rtl_info {
138    unsigned int preferred_incoming_stack_boundary;
139 };
140
141 /* Represent which DECL tree (or reference to such tree)
142    will be replaced by another tree while versioning.  */
143 struct GTY(()) ipa_replace_map
144 {
145   /* The tree that will be replaced.  */
146   tree old_tree;
147   /* The new (replacing) tree.  */
148   tree new_tree;
149   /* True when a substitution should be done, false otherwise.  */
150   bool replace_p;
151   /* True when we replace a reference to old_tree.  */
152   bool ref_p;
153 };
154 typedef struct ipa_replace_map *ipa_replace_map_p;
155 DEF_VEC_P(ipa_replace_map_p);
156 DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
157
158 struct GTY(()) cgraph_clone_info
159 {
160   VEC(ipa_replace_map_p,gc)* tree_map;
161   bitmap args_to_skip;
162   bitmap combined_args_to_skip;
163 };
164
165 /* The cgraph data structure.
166    Each function decl has assigned cgraph_node listing callees and callers.  */
167
168 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
169   tree decl;
170   struct cgraph_edge *callees;
171   struct cgraph_edge *callers;
172   struct cgraph_node *next;
173   struct cgraph_node *previous;
174   /* For nested functions points to function the node is nested in.  */
175   struct cgraph_node *origin;
176   /* Points to first nested function, if any.  */
177   struct cgraph_node *nested;
178   /* Pointer to the next function with same origin, if any.  */
179   struct cgraph_node *next_nested;
180   /* Pointer to the next function in cgraph_nodes_queue.  */
181   struct cgraph_node *next_needed;
182   /* Pointer to the next clone.  */
183   struct cgraph_node *next_sibling_clone;
184   struct cgraph_node *prev_sibling_clone;
185   struct cgraph_node *clones;
186   struct cgraph_node *clone_of;
187   /* For functions with many calls sites it holds map from call expression
188      to the edge to speed up cgraph_edge function.  */
189   htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
190
191   PTR GTY ((skip)) aux;
192
193   struct cgraph_local_info local;
194   struct cgraph_global_info global;
195   struct cgraph_rtl_info rtl;
196   struct cgraph_clone_info clone;
197
198   /* Expected number of executions: calculated in profile.c.  */
199   gcov_type count;
200   /* Unique id of the node.  */
201   int uid;
202   /* Ordering of all cgraph nodes.  */
203   int order;
204
205   /* unique id for profiling. pid is not suitable because of different
206      number of cfg nodes with -fprofile-generate and -fprofile-use */
207   int pid;
208
209   /* Set when function must be output - it is externally visible
210      or its address is taken.  */
211   unsigned needed : 1;
212   /* Set when function has address taken.  */
213   unsigned address_taken : 1;
214   /* Set when decl is an abstract function pointed to by the
215      ABSTRACT_DECL_ORIGIN of a reachable function.  */
216   unsigned abstract_and_needed : 1;
217   /* Set when function is reachable by call from other function
218      that is either reachable or needed.  */
219   unsigned reachable : 1;
220   /* Set once the function is lowered (i.e. its CFG is built).  */
221   unsigned lowered : 1;
222   /* Set once the function has been instantiated and its callee
223      lists created.  */
224   unsigned analyzed : 1;
225   /* Set when function is scheduled to be processed by local passes.  */
226   unsigned process : 1;
227   /* Set for aliases once they got through assemble_alias.  */
228   unsigned alias : 1;
229   /* Set for nodes that was constructed and finalized by frontend.  */
230   unsigned finalized_by_frontend : 1;
231 };
232
233 typedef struct cgraph_node *cgraph_node_ptr;
234
235 DEF_VEC_P(cgraph_node_ptr);
236 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
237 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
238
239 /* A cgraph node set is a collection of cgraph nodes.  A cgraph node
240    can appear in multiple sets.  */
241 struct GTY(()) cgraph_node_set_def
242 {
243   htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
244   VEC(cgraph_node_ptr, gc) *nodes;
245   PTR GTY ((skip)) aux;
246 };
247
248 typedef struct cgraph_node_set_def *cgraph_node_set;
249
250 DEF_VEC_P(cgraph_node_set);
251 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
252 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
253
254 /* A cgraph node set element contains an index in the vector of nodes in
255    the set.  */
256 struct GTY(()) cgraph_node_set_element_def
257 {
258   struct cgraph_node *node;
259   HOST_WIDE_INT index;
260 };
261
262 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
263 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
264
265 /* Iterator structure for cgraph node sets.  */
266 typedef struct
267 {
268   cgraph_node_set set;
269   unsigned index;
270 } cgraph_node_set_iterator;
271
272 #define DEFCIFCODE(code, string)        CIF_ ## code,
273 /* Reasons for inlining failures.  */
274 typedef enum {
275 #include "cif-code.def"
276   CIF_N_REASONS
277 } cgraph_inline_failed_t;
278
279 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
280   struct cgraph_node *caller;
281   struct cgraph_node *callee;
282   struct cgraph_edge *prev_caller;
283   struct cgraph_edge *next_caller;
284   struct cgraph_edge *prev_callee;
285   struct cgraph_edge *next_callee;
286   gimple call_stmt;
287   /* The stmt_uid of this call stmt.  This is used by LTO to recover
288      the call_stmt when the function is serialized in.  */
289   unsigned int lto_stmt_uid;
290   PTR GTY ((skip (""))) aux;
291   /* When equal to CIF_OK, inline this call.  Otherwise, points to the
292      explanation why function was not inlined.  */
293   cgraph_inline_failed_t inline_failed;
294   /* Expected number of executions: calculated in profile.c.  */
295   gcov_type count;
296   /* Expected frequency of executions within the function. 
297      When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
298      per function call.  The range is 0 to CGRAPH_FREQ_MAX.  */
299   int frequency;
300   /* Depth of loop nest, 1 means no loop nest.  */
301   unsigned int loop_nest : 30;
302   /* Whether this edge describes a call that was originally indirect.  */
303   unsigned int indirect_call : 1;
304   /* True if the corresponding CALL stmt cannot be inlined.  */
305   unsigned int call_stmt_cannot_inline_p : 1;
306   /* Can this call throw externally?  */
307   unsigned int can_throw_external : 1;
308   /* Unique id of the edge.  */
309   int uid;
310 };
311
312 #define CGRAPH_FREQ_BASE 1000
313 #define CGRAPH_FREQ_MAX 100000
314
315 typedef struct cgraph_edge *cgraph_edge_p;
316
317 DEF_VEC_P(cgraph_edge_p);
318 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
319
320 /* The varpool data structure.
321    Each static variable decl has assigned varpool_node.  */
322
323 struct GTY((chain_next ("%h.next"))) varpool_node {
324   tree decl;
325   /* Pointer to the next function in varpool_nodes.  */
326   struct varpool_node *next;
327   /* Pointer to the next function in varpool_nodes_queue.  */
328   struct varpool_node *next_needed;
329   /* Ordering of all cgraph nodes.  */
330   int order;
331
332   /* Set when function must be output - it is externally visible
333      or its address is taken.  */
334   unsigned needed : 1;
335   /* Needed variables might become dead by optimization.  This flag
336      forces the variable to be output even if it appears dead otherwise.  */
337   unsigned force_output : 1;
338   /* Set once the variable has been instantiated and its callee
339      lists created.  */
340   unsigned analyzed : 1;
341   /* Set once it has been finalized so we consider it to be output.  */
342   unsigned finalized : 1;
343   /* Set when variable is scheduled to be assembled.  */
344   unsigned output : 1;
345   /* Set when function is visible by other units.  */
346   unsigned externally_visible : 1;
347   /* Set for aliases once they got through assemble_alias.  */
348   unsigned alias : 1;
349 };
350
351 /* Every top level asm statement is put into a cgraph_asm_node.  */
352
353 struct GTY(()) cgraph_asm_node {
354   /* Next asm node.  */
355   struct cgraph_asm_node *next;
356   /* String for this asm node.  */
357   tree asm_str;
358   /* Ordering of all cgraph nodes.  */
359   int order;
360 };
361
362 extern GTY(()) struct cgraph_node *cgraph_nodes;
363 extern GTY(()) int cgraph_n_nodes;
364 extern GTY(()) int cgraph_max_uid;
365 extern GTY(()) int cgraph_edge_max_uid;
366 extern GTY(()) int cgraph_max_pid;
367 extern bool cgraph_global_info_ready;
368 enum cgraph_state
369 {
370   /* Callgraph is being constructed.  It is safe to add new functions.  */
371   CGRAPH_STATE_CONSTRUCTION,
372   /* Callgraph is built and IPA passes are being run.  */
373   CGRAPH_STATE_IPA,
374   /* Callgraph is built and all functions are transformed to SSA form.  */
375   CGRAPH_STATE_IPA_SSA,
376   /* Functions are now ordered and being passed to RTL expanders.  */
377   CGRAPH_STATE_EXPANSION,
378   /* All cgraph expansion is done.  */
379   CGRAPH_STATE_FINISHED
380 };
381 extern enum cgraph_state cgraph_state;
382 extern bool cgraph_function_flags_ready;
383 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
384 extern GTY(()) struct cgraph_node *cgraph_new_nodes;
385
386 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
387 extern GTY(()) int cgraph_order;
388
389 /* In cgraph.c  */
390 void dump_cgraph (FILE *);
391 void debug_cgraph (void);
392 void dump_cgraph_node (FILE *, struct cgraph_node *);
393 void debug_cgraph_node (struct cgraph_node *);
394 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
395 void cgraph_remove_edge (struct cgraph_edge *);
396 void cgraph_remove_node (struct cgraph_node *);
397 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
398 void cgraph_release_function_body (struct cgraph_node *);
399 void cgraph_node_remove_callees (struct cgraph_node *node);
400 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
401                                         struct cgraph_node *,
402                                         gimple, gcov_type, int, int);
403
404 struct cgraph_node * cgraph_get_node (tree);
405 struct cgraph_node *cgraph_node (tree);
406 struct cgraph_node *cgraph_node_for_asm (tree);
407 struct cgraph_node *cgraph_node_for_decl (tree);
408 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
409 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
410 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
411 void cgraph_create_edge_including_clones (struct cgraph_node *,
412                                           struct cgraph_node *,
413                                           gimple, gcov_type, int, int,
414                                           cgraph_inline_failed_t);
415 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
416 struct cgraph_local_info *cgraph_local_info (tree);
417 struct cgraph_global_info *cgraph_global_info (tree);
418 struct cgraph_rtl_info *cgraph_rtl_info (tree);
419 const char * cgraph_node_name (struct cgraph_node *);
420 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
421                                         struct cgraph_node *, gimple,
422                                         unsigned, gcov_type, int, int, bool);
423 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int,
424                                         int, bool, VEC(cgraph_edge_p,heap) *);
425
426 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
427
428 struct cgraph_asm_node *cgraph_add_asm_node (tree);
429
430 bool cgraph_function_possibly_inlined_p (tree);
431 void cgraph_unnest_node (struct cgraph_node *);
432
433 enum availability cgraph_function_body_availability (struct cgraph_node *);
434 void cgraph_add_new_function (tree, bool);
435 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
436 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
437                                                   VEC(cgraph_edge_p,heap)*,
438                                                   VEC(ipa_replace_map_p,gc)* tree_map,
439                                                   bitmap args_to_skip);
440
441 /* In cgraphunit.c  */
442 void cgraph_finalize_function (tree, bool);
443 void cgraph_mark_if_needed (tree);
444 void cgraph_finalize_compilation_unit (void);
445 void cgraph_optimize (void);
446 void cgraph_mark_needed_node (struct cgraph_node *);
447 void cgraph_mark_address_taken_node (struct cgraph_node *);
448 void cgraph_mark_reachable_node (struct cgraph_node *);
449 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
450 bool cgraph_preserve_function_body_p (tree);
451 void verify_cgraph (void);
452 void verify_cgraph_node (struct cgraph_node *);
453 void cgraph_build_static_cdtor (char which, tree body, int priority);
454 void cgraph_reset_static_var_maps (void);
455 void init_cgraph (void);
456 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
457                                                 VEC(cgraph_edge_p,heap)*,
458                                                 VEC(ipa_replace_map_p,gc)*,
459                                                 bitmap);
460 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
461 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
462 void record_references_in_initializer (tree, bool);
463 bool cgraph_process_new_functions (void);
464
465 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
466
467 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
468 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
469 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
470                                   void *);
471 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
472                                   void *);
473 struct cgraph_edge_hook_list;
474 struct cgraph_node_hook_list;
475 struct cgraph_2edge_hook_list;
476 struct cgraph_2node_hook_list;
477 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
478 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
479 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
480                                                             void *);
481 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
482 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
483                                                                   void *);
484 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
485 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
486 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
487 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
488 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
489 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
490 void cgraph_materialize_all_clones (void);
491
492 /* In cgraphbuild.c  */
493 unsigned int rebuild_cgraph_edges (void);
494 void reset_inline_failed (struct cgraph_node *);
495 int compute_call_stmt_bb_frequency (tree, basic_block bb);
496
497 /* In ipa.c  */
498 bool cgraph_remove_unreachable_nodes (bool, FILE *);
499 int cgraph_postorder (struct cgraph_node **);
500 cgraph_node_set cgraph_node_set_new (void);
501 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
502                                                struct cgraph_node *);
503 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
504 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
505 void dump_cgraph_node_set (FILE *, cgraph_node_set);
506 void debug_cgraph_node_set (cgraph_node_set);
507
508
509 /* In predict.c  */
510 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
511
512 /* In varpool.c  */
513 extern GTY(()) struct varpool_node *varpool_nodes_queue;
514 extern GTY(()) struct varpool_node *varpool_nodes;
515
516 struct varpool_node *varpool_node (tree);
517 struct varpool_node *varpool_node_for_asm (tree asmname);
518 void varpool_mark_needed_node (struct varpool_node *);
519 void debug_varpool (void);
520 void dump_varpool (FILE *);
521 void dump_varpool_node (FILE *, struct varpool_node *);
522
523 void varpool_finalize_decl (tree);
524 bool decide_is_variable_needed (struct varpool_node *, tree);
525 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
526 void cgraph_make_node_local (struct cgraph_node *);
527 bool cgraph_node_can_be_local_p (struct cgraph_node *);
528
529 bool varpool_assemble_pending_decls (void);
530 bool varpool_assemble_decl (struct varpool_node *node);
531 bool varpool_analyze_pending_decls (void);
532 void varpool_remove_unreferenced_decls (void);
533 void varpool_empty_needed_queue (void);
534
535 /* Walk all reachable static variables.  */
536 #define FOR_EACH_STATIC_VARIABLE(node) \
537    for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
538
539 /* Return first reachable static variable with initializer.  */
540 static inline struct varpool_node *
541 varpool_first_static_initializer (void)
542 {
543   struct varpool_node *node;
544   for (node = varpool_nodes_queue; node; node = node->next_needed)
545     {
546       gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
547       if (DECL_INITIAL (node->decl))
548         return node;
549     }
550   return NULL;
551 }
552
553 /* Return next reachable static variable with initializer after NODE.  */
554 static inline struct varpool_node *
555 varpool_next_static_initializer (struct varpool_node *node)
556 {
557   for (node = node->next_needed; node; node = node->next_needed)
558     {
559       gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
560       if (DECL_INITIAL (node->decl))
561         return node;
562     }
563   return NULL;
564 }
565
566 /* Walk all static variables with initializer set.  */
567 #define FOR_EACH_STATIC_INITIALIZER(node) \
568    for ((node) = varpool_first_static_initializer (); (node); \
569         (node) = varpool_next_static_initializer (node))
570
571 /* In ipa-inline.c  */
572 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
573 unsigned int compute_inline_parameters (struct cgraph_node *);
574
575
576 /* Create a new static variable of type TYPE.  */
577 tree add_new_static_var (tree type);
578
579 /* lto-cgraph.c */
580
581 enum LTO_cgraph_tags
582 {
583   /* Must leave 0 for the stopper.  */
584   LTO_cgraph_avail_node = 1,
585   LTO_cgraph_overwritable_node,
586   LTO_cgraph_unavail_node,
587   LTO_cgraph_edge,
588   LTO_cgraph_last_tag
589 };
590
591 extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag];
592
593 #define LCC_NOT_FOUND   (-1)
594
595
596 /* Return true if iterator CSI points to nothing.  */
597 static inline bool
598 csi_end_p (cgraph_node_set_iterator csi)
599 {
600   return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
601 }
602
603 /* Advance iterator CSI.  */
604 static inline void
605 csi_next (cgraph_node_set_iterator *csi)
606 {
607   csi->index++;
608 }
609
610 /* Return the node pointed to by CSI.  */
611 static inline struct cgraph_node *
612 csi_node (cgraph_node_set_iterator csi)
613 {
614   return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
615 }
616
617 /* Return an iterator to the first node in SET.  */
618 static inline cgraph_node_set_iterator
619 csi_start (cgraph_node_set set)
620 {
621   cgraph_node_set_iterator csi;
622
623   csi.set = set;
624   csi.index = 0;
625   return csi;
626 }
627
628 /* Return true if SET contains NODE.  */
629 static inline bool
630 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
631 {
632   cgraph_node_set_iterator csi;
633   csi = cgraph_node_set_find (set, node);
634   return !csi_end_p (csi);
635 }
636
637 /* Return number of nodes in SET.  */
638 static inline size_t
639 cgraph_node_set_size (cgraph_node_set set)
640 {
641   return htab_elements (set->hashtab);
642 }
643
644 /* Uniquize all constants that appear in memory.
645    Each constant in memory thus far output is recorded
646    in `const_desc_table'.  */
647
648 struct GTY(()) constant_descriptor_tree {
649   /* A MEM for the constant.  */
650   rtx rtl;
651   
652   /* The value of the constant.  */
653   tree value;
654
655   /* Hash of value.  Computing the hash from value each time
656      hashfn is called can't work properly, as that means recursive
657      use of the hash table during hash table expansion.  */
658   hashval_t hash;
659 };
660
661 /* Return true when function NODE is only called directly.
662    i.e. it is not externally visible, address was not taken and
663    it is not used in any other non-standard way.  */
664
665 static inline bool
666 cgraph_only_called_directly_p (struct cgraph_node *node)
667 {
668   return !node->needed && !node->local.externally_visible;
669 }
670
671 /* Return true when function NODE can be removed from callgraph
672    if all direct calls are eliminated.  */
673
674 static inline bool
675 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
676 {
677   return (!node->needed
678           && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
679 }
680
681 /* Constant pool accessor function.  */
682 htab_t constant_pool_htab (void);
683
684 #endif  /* GCC_CGRAPH_H  */