source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/tools/avr/lib/gcc/avr/4.9.2/plugin/include/ipa-utils.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 6.5 KB
Line 
1/* Utilities for ipa analysis.
2   Copyright (C) 2004-2014 Free Software Foundation, Inc.
3   Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3.  If not see
19<http://www.gnu.org/licenses/>.  */
20
21#ifndef GCC_IPA_UTILS_H
22#define GCC_IPA_UTILS_H
23#include "cgraph.h"
24
25struct ipa_dfs_info {
26  int dfn_number;
27  int low_link;
28  /* This field will have the samy value for any two nodes in the same strongly
29     connected component.  */
30  int scc_no;
31  bool new_node;
32  bool on_stack;
33  struct cgraph_node* next_cycle;
34  PTR aux;
35};
36
37/* Context of polymorphic call.  This is used by ipa-devirt walkers of the
38   type inheritance graph.  */
39struct ipa_polymorphic_call_context {
40  /* The called object appears in an object of type OUTER_TYPE
41     at offset OFFSET.  */
42  HOST_WIDE_INT offset;
43  tree outer_type;
44  /* True if outer object may be in construction or destruction.  */
45  bool maybe_in_construction;
46  /* True if outer object may be of derived type.  */
47  bool maybe_derived_type;
48};
49
50/* Context representing "I know nothing".  */
51extern const ipa_polymorphic_call_context ipa_dummy_polymorphic_call_context;
52
53/* In ipa-utils.c  */
54void ipa_print_order (FILE*, const char *, struct cgraph_node**, int);
55int ipa_reduced_postorder (struct cgraph_node **, bool, bool,
56                          bool (*ignore_edge) (struct cgraph_edge *));
57void ipa_free_postorder_info (void);
58vec<cgraph_node_ptr> ipa_get_nodes_in_cycle (struct cgraph_node *);
59bool ipa_edge_within_scc (struct cgraph_edge *);
60int ipa_reverse_postorder (struct cgraph_node **);
61tree get_base_var (tree);
62void ipa_merge_profiles (struct cgraph_node *dst,
63                         struct cgraph_node *src);
64bool recursive_call_p (tree, tree);
65
66/* In ipa-profile.c  */
67bool ipa_propagate_frequency (struct cgraph_node *node);
68
69/* In ipa-devirt.c  */
70
71struct odr_type_d;
72typedef odr_type_d *odr_type;
73void build_type_inheritance_graph (void);
74void update_type_inheritance_graph (void);
75vec <cgraph_node *>
76possible_polymorphic_call_targets (tree, HOST_WIDE_INT,
77                                   ipa_polymorphic_call_context,
78                                   bool *final = NULL,
79                                   void **cache_token = NULL,
80                                   int *nonconstruction_targets = NULL);
81odr_type get_odr_type (tree, bool insert = false);
82void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT,
83                                             const ipa_polymorphic_call_context &);
84bool possible_polymorphic_call_target_p (tree, HOST_WIDE_INT,
85                                         const ipa_polymorphic_call_context &,
86                                         struct cgraph_node *n);
87tree method_class_type (tree);
88tree get_polymorphic_call_info (tree, tree, tree *,
89                                HOST_WIDE_INT *,
90                                ipa_polymorphic_call_context *);
91bool get_polymorphic_call_info_from_invariant (ipa_polymorphic_call_context *,
92                                               tree, tree, HOST_WIDE_INT);
93tree vtable_pointer_value_to_binfo (tree t);
94bool vtable_pointer_value_to_vtable (tree, tree *, unsigned HOST_WIDE_INT *);
95
96/* Return vector containing possible targets of polymorphic call E.
97   If FINALP is non-NULL, store true if the list is complette.
98   CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry
99   in the target cache.  If user needs to visit every target list
100   just once, it can memoize them.
101
102   Returned vector is placed into cache.  It is NOT caller's responsibility
103   to free it.  The vector can be freed on cgraph_remove_node call if
104   the particular node is a virtual function present in the cache.  */
105
106inline vec <cgraph_node *>
107possible_polymorphic_call_targets (struct cgraph_edge *e,
108                                   bool *final = NULL,
109                                   void **cache_token = NULL,
110                                   int *nonconstruction_targets = NULL)
111{
112  gcc_checking_assert (e->indirect_info->polymorphic);
113  ipa_polymorphic_call_context context = {e->indirect_info->offset,
114                                          e->indirect_info->outer_type,
115                                          e->indirect_info->maybe_in_construction,
116                                          e->indirect_info->maybe_derived_type};
117  return possible_polymorphic_call_targets (e->indirect_info->otr_type,
118                                            e->indirect_info->otr_token,
119                                            context,
120                                            final, cache_token,
121                                            nonconstruction_targets);
122}
123
124/* Same as above but taking OBJ_TYPE_REF as an parameter.  */
125
126inline vec <cgraph_node *>
127possible_polymorphic_call_targets (tree call,
128                                   bool *final = NULL,
129                                   void **cache_token = NULL)
130{
131  tree otr_type;
132  HOST_WIDE_INT otr_token;
133  ipa_polymorphic_call_context context;
134
135  get_polymorphic_call_info (current_function_decl,
136                             call,
137                             &otr_type, &otr_token, &context);
138  return possible_polymorphic_call_targets (obj_type_ref_class (call),
139                                            tree_to_uhwi
140                                              (OBJ_TYPE_REF_TOKEN (call)),
141                                            context,
142                                            final, cache_token);
143}
144
145/* Dump possible targets of a polymorphic call E into F.  */
146
147inline void
148dump_possible_polymorphic_call_targets (FILE *f, struct cgraph_edge *e)
149{
150  gcc_checking_assert (e->indirect_info->polymorphic);
151  ipa_polymorphic_call_context context = {e->indirect_info->offset,
152                                          e->indirect_info->outer_type,
153                                          e->indirect_info->maybe_in_construction,
154                                          e->indirect_info->maybe_derived_type};
155  dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type,
156                                          e->indirect_info->otr_token,
157                                          context);
158}
159
160/* Return true if N can be possibly target of a polymorphic call of
161   E.  */
162
163inline bool
164possible_polymorphic_call_target_p (struct cgraph_edge *e,
165                                    struct cgraph_node *n)
166{
167  ipa_polymorphic_call_context context = {e->indirect_info->offset,
168                                          e->indirect_info->outer_type,
169                                          e->indirect_info->maybe_in_construction,
170                                          e->indirect_info->maybe_derived_type};
171  return possible_polymorphic_call_target_p (e->indirect_info->otr_type,
172                                             e->indirect_info->otr_token,
173                                             context, n);
174}
175
176/* Return true if N can be possibly target of a polymorphic call of
177   OBJ_TYPE_REF expression CALL.  */
178
179inline bool
180possible_polymorphic_call_target_p (tree call,
181                                    struct cgraph_node *n)
182{
183  return possible_polymorphic_call_target_p (obj_type_ref_class (call),
184                                             tree_to_uhwi
185                                               (OBJ_TYPE_REF_TOKEN (call)),
186                                             ipa_dummy_polymorphic_call_context,
187                                             n);
188}
189#endif  /* GCC_IPA_UTILS_H  */
190
191
Note: See TracBrowser for help on using the repository browser.