Merge branch 'vendor/GCC50' - gcc 5.0 snapshot 1 FEB 2015
[dragonfly.git] / contrib / gcc-5.0 / gcc / gimple-ssa.h
1 /* Header file for routines that straddle the border between GIMPLE and
2    SSA in gimple.
3    Copyright (C) 2009-2015 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License 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_GIMPLE_SSA_H
22 #define GCC_GIMPLE_SSA_H
23
24 #include "hash-map.h"
25 #include "tree-hasher.h"
26 #include "tree-ssa-operands.h"
27
28 /* This structure is used to map a gimple statement to a label,
29    or list of labels to represent transaction restart.  */
30
31 struct GTY((for_user)) tm_restart_node {
32   gimple stmt;
33   tree label_or_list;
34 };
35
36 /* Hasher for tm_restart_node.  */
37
38 struct tm_restart_hasher : ggc_hasher<tm_restart_node *>
39 {
40   static hashval_t hash (tm_restart_node *n) { return htab_hash_pointer (n); }
41
42   static bool
43   equal (tm_restart_node *a, tm_restart_node *b)
44   {
45     return a == b;
46   }
47 };
48
49 struct ssa_name_hasher : ggc_hasher<tree>
50 {
51   /* Hash a tree in a uid_decl_map.  */
52
53   static hashval_t
54   hash (tree item)
55   {
56     return item->ssa_name.var->decl_minimal.uid;
57   }
58
59   /* Return true if the DECL_UID in both trees are equal.  */
60
61   static bool
62   equal (tree a, tree b)
63 {
64   return (a->ssa_name.var->decl_minimal.uid == b->ssa_name.var->decl_minimal.uid);
65 }
66 };
67
68 /* Gimple dataflow datastructure. All publicly available fields shall have
69    gimple_ accessor defined, all publicly modifiable fields should have
70    gimple_set accessor.  */
71 struct GTY(()) gimple_df {
72   /* A vector of all the noreturn calls passed to modify_stmt.
73      cleanup_control_flow uses it to detect cases where a mid-block
74      indirect call has been turned into a noreturn call.  When this
75      happens, all the instructions after the call are no longer
76      reachable and must be deleted as dead.  */
77   vec<gimple, va_gc> *modified_noreturn_calls;
78
79   /* Array of all SSA_NAMEs used in the function.  */
80   vec<tree, va_gc> *ssa_names;
81
82   /* Artificial variable used for the virtual operand FUD chain.  */
83   tree vop;
84
85   /* The PTA solution for the ESCAPED artificial variable.  */
86   struct pt_solution escaped;
87
88   /* A map of decls to artificial ssa-names that point to the partition
89      of the decl.  */
90   hash_map<tree, tree> * GTY((skip(""))) decls_to_pointers;
91
92   /* Free list of SSA_NAMEs.  */
93   vec<tree, va_gc> *free_ssanames;
94
95   /* Hashtable holding definition for symbol.  If this field is not NULL, it
96      means that the first reference to this variable in the function is a
97      USE or a VUSE.  In those cases, the SSA renamer creates an SSA name
98      for this variable with an empty defining statement.  */
99   hash_table<ssa_name_hasher> *default_defs;
100
101   /* True if there are any symbols that need to be renamed.  */
102   unsigned int ssa_renaming_needed : 1;
103
104   /* True if all virtual operands need to be renamed.  */
105   unsigned int rename_vops : 1;
106
107   /* True if the code is in ssa form.  */
108   unsigned int in_ssa_p : 1;
109
110   /* True if IPA points-to information was computed for this function.  */
111   unsigned int ipa_pta : 1;
112
113   struct ssa_operands ssa_operands;
114
115   /* Map gimple stmt to tree label (or list of labels) for transaction
116      restart and abort.  */
117   hash_table<tm_restart_hasher> *tm_restart;
118 };
119
120
121 /* Return true when gimple SSA form was built.
122    gimple_in_ssa_p is queried by gimplifier in various early stages before SSA
123    infrastructure is initialized.  Check for presence of the datastructures
124    at first place.  */
125 static inline bool
126 gimple_in_ssa_p (const struct function *fun)
127 {
128   return fun && fun->gimple_df && fun->gimple_df->in_ssa_p;
129 }
130
131 /* Artificial variable used for the virtual operand FUD chain.  */
132 static inline tree
133 gimple_vop (const struct function *fun)
134 {
135   gcc_checking_assert (fun && fun->gimple_df);
136   return fun->gimple_df->vop;
137 }
138
139 /* Return the set of VUSE operand for statement G.  */
140
141 static inline use_operand_p
142 gimple_vuse_op (const_gimple g)
143 {
144   struct use_optype_d *ops;
145   const gimple_statement_with_memory_ops *mem_ops_stmt =
146      dyn_cast <const gimple_statement_with_memory_ops *> (g);
147   if (!mem_ops_stmt)
148     return NULL_USE_OPERAND_P;
149   ops = mem_ops_stmt->use_ops;
150   if (ops
151       && USE_OP_PTR (ops)->use == &mem_ops_stmt->vuse)
152     return USE_OP_PTR (ops);
153   return NULL_USE_OPERAND_P;
154 }
155
156 /* Return the set of VDEF operand for statement G.  */
157
158 static inline def_operand_p
159 gimple_vdef_op (gimple g)
160 {
161   gimple_statement_with_memory_ops *mem_ops_stmt =
162      dyn_cast <gimple_statement_with_memory_ops *> (g);
163   if (!mem_ops_stmt)
164     return NULL_DEF_OPERAND_P;
165   if (mem_ops_stmt->vdef)
166     return &mem_ops_stmt->vdef;
167   return NULL_DEF_OPERAND_P;
168 }
169
170 /* Mark statement S as modified, and update it.  */
171
172 static inline void
173 update_stmt (gimple s)
174 {
175   if (gimple_has_ops (s))
176     {
177       gimple_set_modified (s, true);
178       update_stmt_operands (cfun, s);
179     }
180 }
181
182 /* Update statement S if it has been optimized.  */
183
184 static inline void
185 update_stmt_if_modified (gimple s)
186 {
187   if (gimple_modified_p (s))
188     update_stmt_operands (cfun, s);
189 }
190
191 /* Mark statement S as modified, and update it.  */
192
193 static inline void
194 update_stmt_fn (struct function *fn, gimple s)
195 {
196   if (gimple_has_ops (s))
197     {
198       gimple_set_modified (s, true);
199       update_stmt_operands (fn, s);
200     }
201 }
202
203
204 #endif /* GCC_GIMPLE_SSA_H */