]>
Commit | Line | Data |
---|---|---|
8d810329 | 1 | /* IPA reference lists. |
71e45bc2 | 2 | Copyright (C) 2010, 2012 |
8d810329 | 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 | ||
04ec15fa | 22 | /* Return callgraph node REF is referring. */ |
8d810329 | 23 | static inline struct cgraph_node * |
24 | ipa_ref_node (struct ipa_ref *ref) | |
25 | { | |
04ec15fa | 26 | return cgraph (ref->referred); |
8d810329 | 27 | } |
28 | ||
04ec15fa | 29 | /* Return varpool node REF is referring. */ |
8d810329 | 30 | |
31 | static inline struct varpool_node * | |
32 | ipa_ref_varpool_node (struct ipa_ref *ref) | |
33 | { | |
04ec15fa | 34 | return varpool (ref->referred); |
8d810329 | 35 | } |
36 | ||
37 | /* Return cgraph node REF is in. */ | |
38 | ||
39 | static inline struct cgraph_node * | |
04ec15fa | 40 | ipa_ref_referring_node (struct ipa_ref *ref) |
8d810329 | 41 | { |
04ec15fa | 42 | return cgraph (ref->referring); |
8d810329 | 43 | } |
44 | ||
45 | /* Return varpool node REF is in. */ | |
46 | ||
47 | static inline struct varpool_node * | |
04ec15fa | 48 | ipa_ref_referring_varpool_node (struct ipa_ref *ref) |
8d810329 | 49 | { |
04ec15fa | 50 | return varpool (ref->referring); |
8d810329 | 51 | } |
52 | ||
53 | /* Return reference list REF is in. */ | |
54 | ||
55 | static inline struct ipa_ref_list * | |
04ec15fa | 56 | ipa_ref_referring_ref_list (struct ipa_ref *ref) |
8d810329 | 57 | { |
04ec15fa | 58 | return &ref->referring->symbol.ref_list; |
8d810329 | 59 | } |
60 | ||
61 | /* Return reference list REF is in. */ | |
62 | ||
63 | static inline struct ipa_ref_list * | |
04ec15fa | 64 | ipa_ref_referred_ref_list (struct ipa_ref *ref) |
8d810329 | 65 | { |
04ec15fa | 66 | return &ref->referred->symbol.ref_list; |
8d810329 | 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 | { | |
f1f41a6c | 74 | if (!vec_safe_length (list->references)) |
8d810329 | 75 | return NULL; |
f1f41a6c | 76 | return &(*list->references)[0]; |
8d810329 | 77 | } |
78 | ||
04ec15fa | 79 | /* Return first referring ref in LIST or NULL if empty. */ |
8d810329 | 80 | |
81 | static inline struct ipa_ref * | |
04ec15fa | 82 | ipa_ref_list_first_referring (struct ipa_ref_list *list) |
8d810329 | 83 | { |
f1f41a6c | 84 | if (!list->referring.length ()) |
8d810329 | 85 | return NULL; |
f1f41a6c | 86 | return list->referring[0]; |
8d810329 | 87 | } |
88 | ||
89 | /* Clear reference list. */ | |
90 | ||
91 | static inline void | |
92 | ipa_empty_ref_list (struct ipa_ref_list *list) | |
93 | { | |
f1f41a6c | 94 | list->referring.create (0); |
8d810329 | 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 | { | |
f1f41a6c | 103 | return vec_safe_length (list->references); |
8d810329 | 104 | } |
105 | ||
106 | #define ipa_ref_list_reference_iterate(L,I,P) \ | |
f1f41a6c | 107 | vec_safe_iterate ((L)->references, (I), &(P)) |
04ec15fa | 108 | #define ipa_ref_list_referring_iterate(L,I,P) \ |
f1f41a6c | 109 | (L)->referring.iterate ((I), &(P)) |