* dwarf2out.c (modified_type_die, gen_reference_type_die): Use
[official-gcc.git] / gcc / ipa-ref-inline.h
blob6ca9ba08f30df773bf6e3d2e12db7da135b2bd8c
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 refering. */
23 static inline struct cgraph_node *
24 ipa_ref_node (struct ipa_ref *ref)
26 gcc_assert (ref->refered_type == IPA_REF_CGRAPH);
27 return ref->refered.cgraph_node;
30 /* Return varpool node REF is refering. */
32 static inline struct varpool_node *
33 ipa_ref_varpool_node (struct ipa_ref *ref)
35 gcc_assert (ref->refered_type == IPA_REF_VARPOOL);
36 return ref->refered.varpool_node;
39 /* Return cgraph node REF is in. */
41 static inline struct cgraph_node *
42 ipa_ref_refering_node (struct ipa_ref *ref)
44 gcc_assert (ref->refering_type == IPA_REF_CGRAPH);
45 return ref->refering.cgraph_node;
48 /* Return varpool node REF is in. */
50 static inline struct varpool_node *
51 ipa_ref_refering_varpool_node (struct ipa_ref *ref)
53 gcc_assert (ref->refering_type == IPA_REF_VARPOOL);
54 return ref->refering.varpool_node;
57 /* Return reference list REF is in. */
59 static inline struct ipa_ref_list *
60 ipa_ref_refering_ref_list (struct ipa_ref *ref)
62 if (ref->refering_type == IPA_REF_CGRAPH)
63 return &ipa_ref_refering_node (ref)->ref_list;
64 else
65 return &ipa_ref_refering_varpool_node (ref)->ref_list;
68 /* Return reference list REF is in. */
70 static inline struct ipa_ref_list *
71 ipa_ref_refered_ref_list (struct ipa_ref *ref)
73 if (ref->refered_type == IPA_REF_CGRAPH)
74 return &ipa_ref_node (ref)->ref_list;
75 else
76 return &ipa_ref_varpool_node (ref)->ref_list;
79 /* Return first reference in LIST or NULL if empty. */
81 static inline struct ipa_ref *
82 ipa_ref_list_first_reference (struct ipa_ref_list *list)
84 if (!VEC_length (ipa_ref_t, list->references))
85 return NULL;
86 return VEC_index (ipa_ref_t, list->references, 0);
89 /* Return first refering ref in LIST or NULL if empty. */
91 static inline struct ipa_ref *
92 ipa_ref_list_first_refering (struct ipa_ref_list *list)
94 if (!VEC_length (ipa_ref_ptr, list->refering))
95 return NULL;
96 return VEC_index (ipa_ref_ptr, list->refering, 0);
99 /* Clear reference list. */
101 static inline void
102 ipa_empty_ref_list (struct ipa_ref_list *list)
104 list->refering = NULL;
105 list->references = NULL;
108 /* Clear reference list. */
110 static inline unsigned int
111 ipa_ref_list_nreferences (struct ipa_ref_list *list)
113 return VEC_length (ipa_ref_t, list->references);
116 #define ipa_ref_list_reference_iterate(L,I,P) \
117 VEC_iterate(ipa_ref_t, (L)->references, (I), (P))
118 #define ipa_ref_list_refering_iterate(L,I,P) \
119 VEC_iterate(ipa_ref_ptr, (L)->refering, (I), (P))