]>
Commit | Line | Data |
---|---|---|
369451ec | 1 | /* IPA reference lists. |
23a5b65a | 2 | Copyright (C) 2010-2014 Free Software Foundation, Inc. |
369451ec JH |
3 | Contributed by Jan Hubicka |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
5932a4d4 | 21 | /* Return callgraph node REF is referring. */ |
369451ec JH |
22 | static inline struct cgraph_node * |
23 | ipa_ref_node (struct ipa_ref *ref) | |
24 | { | |
5932a4d4 | 25 | return cgraph (ref->referred); |
369451ec JH |
26 | } |
27 | ||
5932a4d4 | 28 | /* Return varpool node REF is referring. */ |
369451ec | 29 | |
2c8326a5 | 30 | static inline varpool_node * |
369451ec JH |
31 | ipa_ref_varpool_node (struct ipa_ref *ref) |
32 | { | |
5932a4d4 | 33 | return varpool (ref->referred); |
369451ec JH |
34 | } |
35 | ||
36 | /* Return cgraph node REF is in. */ | |
37 | ||
38 | static inline struct cgraph_node * | |
5932a4d4 | 39 | ipa_ref_referring_node (struct ipa_ref *ref) |
369451ec | 40 | { |
5932a4d4 | 41 | return cgraph (ref->referring); |
369451ec JH |
42 | } |
43 | ||
44 | /* Return varpool node REF is in. */ | |
45 | ||
2c8326a5 | 46 | static inline varpool_node * |
5932a4d4 | 47 | ipa_ref_referring_varpool_node (struct ipa_ref *ref) |
369451ec | 48 | { |
5932a4d4 | 49 | return varpool (ref->referring); |
369451ec JH |
50 | } |
51 | ||
52 | /* Return reference list REF is in. */ | |
53 | ||
54 | static inline struct ipa_ref_list * | |
5932a4d4 | 55 | ipa_ref_referring_ref_list (struct ipa_ref *ref) |
369451ec | 56 | { |
67348ccc | 57 | return &ref->referring->ref_list; |
369451ec JH |
58 | } |
59 | ||
60 | /* Return reference list REF is in. */ | |
61 | ||
62 | static inline struct ipa_ref_list * | |
5932a4d4 | 63 | ipa_ref_referred_ref_list (struct ipa_ref *ref) |
369451ec | 64 | { |
67348ccc | 65 | return &ref->referred->ref_list; |
369451ec JH |
66 | } |
67 | ||
68 | /* Return first reference in LIST or NULL if empty. */ | |
69 | ||
70 | static inline struct ipa_ref * | |
71 | ipa_ref_list_first_reference (struct ipa_ref_list *list) | |
72 | { | |
9771b263 | 73 | if (!vec_safe_length (list->references)) |
369451ec | 74 | return NULL; |
9771b263 | 75 | return &(*list->references)[0]; |
369451ec JH |
76 | } |
77 | ||
5932a4d4 | 78 | /* Return first referring ref in LIST or NULL if empty. */ |
369451ec JH |
79 | |
80 | static inline struct ipa_ref * | |
5932a4d4 | 81 | ipa_ref_list_first_referring (struct ipa_ref_list *list) |
369451ec | 82 | { |
9771b263 | 83 | if (!list->referring.length ()) |
369451ec | 84 | return NULL; |
9771b263 | 85 | return list->referring[0]; |
369451ec JH |
86 | } |
87 | ||
88 | /* Clear reference list. */ | |
89 | ||
90 | static inline void | |
91 | ipa_empty_ref_list (struct ipa_ref_list *list) | |
92 | { | |
9771b263 | 93 | list->referring.create (0); |
369451ec JH |
94 | list->references = NULL; |
95 | } | |
96 | ||
97 | /* Clear reference list. */ | |
98 | ||
99 | static inline unsigned int | |
100 | ipa_ref_list_nreferences (struct ipa_ref_list *list) | |
101 | { | |
9771b263 | 102 | return vec_safe_length (list->references); |
369451ec JH |
103 | } |
104 | ||
105 | #define ipa_ref_list_reference_iterate(L,I,P) \ | |
9771b263 | 106 | vec_safe_iterate ((L)->references, (I), &(P)) |
5932a4d4 | 107 | #define ipa_ref_list_referring_iterate(L,I,P) \ |
9771b263 | 108 | (L)->referring.iterate ((I), &(P)) |