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