]>
Commit | Line | Data |
---|---|---|
8d810329 | 1 | /* IPA reference lists. |
fbd26352 | 2 | Copyright (C) 2010-2019 Free Software Foundation, Inc. |
8d810329 | 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 | ||
ce6bb0f3 | 21 | #ifndef GCC_IPA_REF_H |
22 | #define GCC_IPA_REF_H | |
23 | ||
8d810329 | 24 | struct cgraph_node; |
2e966e2a | 25 | struct varpool_node; |
26 | struct symtab_node; | |
04ec15fa | 27 | |
8d810329 | 28 | |
29 | /* How the reference is done. */ | |
30 | enum GTY(()) ipa_ref_use | |
31 | { | |
32 | IPA_REF_LOAD, | |
33 | IPA_REF_STORE, | |
c70f46b0 | 34 | IPA_REF_ADDR, |
1e42d5c6 | 35 | IPA_REF_ALIAS |
8d810329 | 36 | }; |
37 | ||
8d810329 | 38 | /* Record of reference in callgraph or varpool. */ |
39 | struct GTY(()) ipa_ref | |
40 | { | |
51ce5652 | 41 | public: |
42 | /* Remove reference. */ | |
43 | void remove_reference (); | |
44 | ||
45 | /* Return true when execution of reference can lead to return from | |
46 | function. */ | |
47 | bool cannot_lead_to_return (); | |
48 | ||
0e62482d | 49 | /* Return true if refernece may be used in address compare. */ |
50 | bool address_matters_p (); | |
51 | ||
51ce5652 | 52 | /* Return reference list this reference is in. */ |
53 | struct ipa_ref_list * referring_ref_list (void); | |
54 | ||
55 | /* Return reference list this reference is in. */ | |
56 | struct ipa_ref_list * referred_ref_list (void); | |
57 | ||
452659af | 58 | symtab_node *referring; |
59 | symtab_node *referred; | |
42acab1c | 60 | gimple *stmt; |
4d044066 | 61 | unsigned int lto_stmt_uid; |
04ec15fa | 62 | unsigned int referred_index; |
058a1b7a | 63 | ENUM_BITFIELD (ipa_ref_use) use:3; |
4d044066 | 64 | unsigned int speculative:1; |
8d810329 | 65 | }; |
66 | ||
67 | typedef struct ipa_ref ipa_ref_t; | |
68 | typedef struct ipa_ref *ipa_ref_ptr; | |
69 | ||
8d810329 | 70 | |
71 | /* List of references. This is stored in both callgraph and varpool nodes. */ | |
72 | struct GTY(()) ipa_ref_list | |
73 | { | |
51ce5652 | 74 | public: |
75 | /* Return first reference in list or NULL if empty. */ | |
76 | struct ipa_ref *first_reference (void) | |
77 | { | |
78 | if (!vec_safe_length (references)) | |
79 | return NULL; | |
80 | return &(*references)[0]; | |
81 | } | |
82 | ||
83 | /* Return first referring ref in list or NULL if empty. */ | |
84 | struct ipa_ref *first_referring (void) | |
85 | { | |
86 | if (!referring.length ()) | |
87 | return NULL; | |
88 | return referring[0]; | |
89 | } | |
90 | ||
e4a2b488 | 91 | /* Return first referring alias. */ |
92 | struct ipa_ref *first_alias (void) | |
93 | { | |
94 | struct ipa_ref *r = first_referring (); | |
95 | ||
96 | return r && r->use == IPA_REF_ALIAS ? r : NULL; | |
97 | } | |
98 | ||
99 | /* Return last referring alias. */ | |
100 | struct ipa_ref *last_alias (void) | |
101 | { | |
102 | unsigned int i = 0; | |
103 | ||
104 | for(i = 0; i < referring.length (); i++) | |
105 | if (referring[i]->use != IPA_REF_ALIAS) | |
106 | break; | |
107 | ||
108 | return i == 0 ? NULL : referring[i - 1]; | |
109 | } | |
110 | ||
111 | /* Return true if the symbol has an alias. */ | |
112 | bool inline has_aliases_p (void) | |
113 | { | |
114 | return first_alias (); | |
115 | } | |
116 | ||
51ce5652 | 117 | /* Clear reference list. */ |
118 | void clear (void) | |
119 | { | |
120 | referring.create (0); | |
121 | references = NULL; | |
122 | } | |
123 | ||
124 | /* Return number of references. */ | |
125 | unsigned int nreferences (void) | |
126 | { | |
127 | return vec_safe_length (references); | |
128 | } | |
129 | ||
8d810329 | 130 | /* Store actual references in references vector. */ |
f1f41a6c | 131 | vec<ipa_ref_t, va_gc> *references; |
9d75589a | 132 | /* Referring is vector of pointers to references. It must not live in GGC space |
8d810329 | 133 | or GGC will try to mark middle of references vectors. */ |
f1f41a6c | 134 | vec<ipa_ref_ptr> GTY((skip)) referring; |
8d810329 | 135 | }; |
ce6bb0f3 | 136 | |
137 | #endif /* GCC_IPA_REF_H */ |