ChangeLog/
[official-gcc.git] / gcc / ipa-ref-inline.h
blob575bba901ac3b2e753769e0d58104b590fd1353e
1 /* IPA reference lists.
2 Copyright (C) 2010
3 Free Software Foundation, Inc.
4 Contributed by Jan Hubicka
6 This file is part of GCC.
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.
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.
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/>. */
22 /* Return callgraph node REF is referring. */
23 static inline struct cgraph_node *
24 ipa_ref_node (struct ipa_ref *ref)
26 return cgraph (ref->referred);
29 /* Return varpool node REF is referring. */
31 static inline struct varpool_node *
32 ipa_ref_varpool_node (struct ipa_ref *ref)
34 return varpool (ref->referred);
37 /* Return cgraph node REF is in. */
39 static inline struct cgraph_node *
40 ipa_ref_referring_node (struct ipa_ref *ref)
42 return cgraph (ref->referring);
45 /* Return varpool node REF is in. */
47 static inline struct varpool_node *
48 ipa_ref_referring_varpool_node (struct ipa_ref *ref)
50 return varpool (ref->referring);
53 /* Return reference list REF is in. */
55 static inline struct ipa_ref_list *
56 ipa_ref_referring_ref_list (struct ipa_ref *ref)
58 return &ref->referring->symbol.ref_list;
61 /* Return reference list REF is in. */
63 static inline struct ipa_ref_list *
64 ipa_ref_referred_ref_list (struct ipa_ref *ref)
66 return &ref->referred->symbol.ref_list;
69 /* Return first reference in LIST or NULL if empty. */
71 static inline struct ipa_ref *
72 ipa_ref_list_first_reference (struct ipa_ref_list *list)
74 if (!VEC_length (ipa_ref_t, list->references))
75 return NULL;
76 return &VEC_index (ipa_ref_t, list->references, 0);
79 /* Return first referring ref in LIST or NULL if empty. */
81 static inline struct ipa_ref *
82 ipa_ref_list_first_referring (struct ipa_ref_list *list)
84 if (!VEC_length (ipa_ref_ptr, list->referring))
85 return NULL;
86 return VEC_index (ipa_ref_ptr, list->referring, 0);
89 /* Clear reference list. */
91 static inline void
92 ipa_empty_ref_list (struct ipa_ref_list *list)
94 list->referring = NULL;
95 list->references = NULL;
98 /* Clear reference list. */
100 static inline unsigned int
101 ipa_ref_list_nreferences (struct ipa_ref_list *list)
103 return VEC_length (ipa_ref_t, list->references);
106 #define ipa_ref_list_reference_iterate(L,I,P) \
107 VEC_iterate(ipa_ref_t, (L)->references, (I), (P))
108 #define ipa_ref_list_referring_iterate(L,I,P) \
109 VEC_iterate(ipa_ref_ptr, (L)->referring, (I), (P))