]>
Commit | Line | Data |
---|---|---|
369451ec | 1 | /* IPA reference lists. |
7adcbafe | 2 | Copyright (C) 2010-2022 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 | ||
f1717f8d KC |
21 | #ifndef GCC_IPA_REF_H |
22 | #define GCC_IPA_REF_H | |
23 | ||
369451ec | 24 | struct cgraph_node; |
99b1c316 MS |
25 | struct varpool_node; |
26 | struct symtab_node; | |
5932a4d4 | 27 | |
369451ec JH |
28 | |
29 | /* How the reference is done. */ | |
7144270e | 30 | enum ipa_ref_use |
369451ec JH |
31 | { |
32 | IPA_REF_LOAD, | |
33 | IPA_REF_STORE, | |
39e2db00 | 34 | IPA_REF_ADDR, |
31db0fe0 | 35 | IPA_REF_ALIAS |
369451ec JH |
36 | }; |
37 | ||
369451ec | 38 | /* Record of reference in callgraph or varpool. */ |
7144270e | 39 | struct ipa_ref |
369451ec | 40 | { |
d122681a ML |
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 | ||
956d615d | 49 | /* Return true if reference may be used in address compare. */ |
5ebd0e61 ML |
50 | bool address_matters_p (); |
51 | ||
d122681a ML |
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 | ||
5e20cdc9 DM |
58 | symtab_node *referring; |
59 | symtab_node *referred; | |
355fe088 | 60 | gimple *stmt; |
042ae7d2 | 61 | unsigned int lto_stmt_uid; |
7144270e | 62 | unsigned int referred_index; |
f1ba88b1 XHL |
63 | /* speculative id is used to link direct calls with their corresponding |
64 | IPA_REF_ADDR references when representing speculative calls. */ | |
65 | unsigned int speculative_id : 16; | |
d5e254e1 | 66 | ENUM_BITFIELD (ipa_ref_use) use:3; |
042ae7d2 | 67 | unsigned int speculative:1; |
369451ec JH |
68 | }; |
69 | ||
70 | typedef struct ipa_ref ipa_ref_t; | |
369451ec | 71 | |
369451ec JH |
72 | |
73 | /* List of references. This is stored in both callgraph and varpool nodes. */ | |
7144270e | 74 | struct ipa_ref_list |
369451ec | 75 | { |
d122681a ML |
76 | public: |
77 | /* Return first reference in list or NULL if empty. */ | |
78 | struct ipa_ref *first_reference (void) | |
79 | { | |
7144270e | 80 | if (!references.length ()) |
d122681a | 81 | return NULL; |
7144270e | 82 | return &references[0]; |
d122681a ML |
83 | } |
84 | ||
85 | /* Return first referring ref in list or NULL if empty. */ | |
86 | struct ipa_ref *first_referring (void) | |
87 | { | |
88 | if (!referring.length ()) | |
89 | return NULL; | |
90 | return referring[0]; | |
91 | } | |
92 | ||
e55637b7 ML |
93 | /* Return first referring alias. */ |
94 | struct ipa_ref *first_alias (void) | |
95 | { | |
96 | struct ipa_ref *r = first_referring (); | |
97 | ||
98 | return r && r->use == IPA_REF_ALIAS ? r : NULL; | |
99 | } | |
100 | ||
101 | /* Return last referring alias. */ | |
102 | struct ipa_ref *last_alias (void) | |
103 | { | |
104 | unsigned int i = 0; | |
105 | ||
106 | for(i = 0; i < referring.length (); i++) | |
107 | if (referring[i]->use != IPA_REF_ALIAS) | |
108 | break; | |
109 | ||
110 | return i == 0 ? NULL : referring[i - 1]; | |
111 | } | |
112 | ||
113 | /* Return true if the symbol has an alias. */ | |
114 | bool inline has_aliases_p (void) | |
115 | { | |
116 | return first_alias (); | |
117 | } | |
118 | ||
d122681a ML |
119 | /* Clear reference list. */ |
120 | void clear (void) | |
121 | { | |
122 | referring.create (0); | |
7144270e | 123 | references.create (0); |
d122681a ML |
124 | } |
125 | ||
126 | /* Return number of references. */ | |
127 | unsigned int nreferences (void) | |
128 | { | |
7144270e | 129 | return references.length (); |
d122681a ML |
130 | } |
131 | ||
369451ec | 132 | /* Store actual references in references vector. */ |
7144270e | 133 | vec<ipa_ref_t, va_heap, vl_ptr> references; |
073a8998 | 134 | /* Referring is vector of pointers to references. It must not live in GGC space |
369451ec | 135 | or GGC will try to mark middle of references vectors. */ |
7144270e | 136 | vec<ipa_ref_t *, va_heap, vl_ptr> referring; |
369451ec | 137 | }; |
f1717f8d KC |
138 | |
139 | #endif /* GCC_IPA_REF_H */ |