]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ipa-ref-inline.h
636af145789384364258c7b3e7b6ea320cbb432c
[thirdparty/gcc.git] / gcc / ipa-ref-inline.h
1 /* IPA reference lists.
2 Copyright (C) 2010
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 /* Return callgraph node REF is referring. */
23 static inline struct cgraph_node *
24 ipa_ref_node (struct ipa_ref *ref)
25 {
26 return cgraph (ref->referred);
27 }
28
29 /* Return varpool node REF is referring. */
30
31 static inline struct varpool_node *
32 ipa_ref_varpool_node (struct ipa_ref *ref)
33 {
34 return varpool (ref->referred);
35 }
36
37 /* Return cgraph node REF is in. */
38
39 static inline struct cgraph_node *
40 ipa_ref_referring_node (struct ipa_ref *ref)
41 {
42 return cgraph (ref->referring);
43 }
44
45 /* Return varpool node REF is in. */
46
47 static inline struct varpool_node *
48 ipa_ref_referring_varpool_node (struct ipa_ref *ref)
49 {
50 return varpool (ref->referring);
51 }
52
53 /* Return reference list REF is in. */
54
55 static inline struct ipa_ref_list *
56 ipa_ref_referring_ref_list (struct ipa_ref *ref)
57 {
58 return &ref->referring->symbol.ref_list;
59 }
60
61 /* Return reference list REF is in. */
62
63 static inline struct ipa_ref_list *
64 ipa_ref_referred_ref_list (struct ipa_ref *ref)
65 {
66 return &ref->referred->symbol.ref_list;
67 }
68
69 /* Return first reference in LIST or NULL if empty. */
70
71 static inline struct ipa_ref *
72 ipa_ref_list_first_reference (struct ipa_ref_list *list)
73 {
74 if (!VEC_length (ipa_ref_t, list->references))
75 return NULL;
76 return VEC_index (ipa_ref_t, list->references, 0);
77 }
78
79 /* Return first referring ref in LIST or NULL if empty. */
80
81 static inline struct ipa_ref *
82 ipa_ref_list_first_referring (struct ipa_ref_list *list)
83 {
84 if (!VEC_length (ipa_ref_ptr, list->referring))
85 return NULL;
86 return VEC_index (ipa_ref_ptr, list->referring, 0);
87 }
88
89 /* Clear reference list. */
90
91 static inline void
92 ipa_empty_ref_list (struct ipa_ref_list *list)
93 {
94 list->referring = NULL;
95 list->references = NULL;
96 }
97
98 /* Clear reference list. */
99
100 static inline unsigned int
101 ipa_ref_list_nreferences (struct ipa_ref_list *list)
102 {
103 return VEC_length (ipa_ref_t, list->references);
104 }
105
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))