]>
Commit | Line | Data |
---|---|---|
80560f95 AM |
1 | /* Header file for routines that straddle the border between GIMPLE and |
2 | SSA in gimple. | |
a5544970 | 3 | Copyright (C) 2009-2019 Free Software Foundation, Inc. |
80560f95 AM |
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 | ||
377d9792 AM |
24 | #include "tree-ssa-operands.h" |
25 | ||
cc524fc7 AM |
26 | /* This structure is used to map a gimple statement to a label, |
27 | or list of labels to represent transaction restart. */ | |
28 | ||
50979347 | 29 | struct GTY((for_user)) tm_restart_node { |
355fe088 | 30 | gimple *stmt; |
cc524fc7 AM |
31 | tree label_or_list; |
32 | }; | |
33 | ||
50979347 TS |
34 | /* Hasher for tm_restart_node. */ |
35 | ||
ca752f39 | 36 | struct tm_restart_hasher : ggc_ptr_hash<tm_restart_node> |
50979347 TS |
37 | { |
38 | static hashval_t hash (tm_restart_node *n) { return htab_hash_pointer (n); } | |
39 | ||
40 | static bool | |
41 | equal (tm_restart_node *a, tm_restart_node *b) | |
42 | { | |
43 | return a == b; | |
44 | } | |
45 | }; | |
46 | ||
38fc3edc RB |
47 | extern void gt_ggc_mx (gimple *&); |
48 | extern void gt_pch_nx (gimple *&); | |
49 | ||
ca752f39 | 50 | struct ssa_name_hasher : ggc_ptr_hash<tree_node> |
2a22f99c TS |
51 | { |
52 | /* Hash a tree in a uid_decl_map. */ | |
53 | ||
54 | static hashval_t | |
55 | hash (tree item) | |
56 | { | |
57 | return item->ssa_name.var->decl_minimal.uid; | |
58 | } | |
59 | ||
60 | /* Return true if the DECL_UID in both trees are equal. */ | |
61 | ||
62 | static bool | |
63 | equal (tree a, tree b) | |
64 | { | |
65 | return (a->ssa_name.var->decl_minimal.uid == b->ssa_name.var->decl_minimal.uid); | |
66 | } | |
67 | }; | |
68 | ||
cc524fc7 AM |
69 | /* Gimple dataflow datastructure. All publicly available fields shall have |
70 | gimple_ accessor defined, all publicly modifiable fields should have | |
71 | gimple_set accessor. */ | |
72 | struct GTY(()) gimple_df { | |
cc524fc7 AM |
73 | /* Array of all SSA_NAMEs used in the function. */ |
74 | vec<tree, va_gc> *ssa_names; | |
75 | ||
76 | /* Artificial variable used for the virtual operand FUD chain. */ | |
77 | tree vop; | |
78 | ||
79 | /* The PTA solution for the ESCAPED artificial variable. */ | |
80 | struct pt_solution escaped; | |
81 | ||
82 | /* A map of decls to artificial ssa-names that point to the partition | |
83 | of the decl. */ | |
39c8aaa4 | 84 | hash_map<tree, tree> * GTY((skip(""))) decls_to_pointers; |
cc524fc7 AM |
85 | |
86 | /* Free list of SSA_NAMEs. */ | |
87 | vec<tree, va_gc> *free_ssanames; | |
88 | ||
dc0ccbb3 BS |
89 | /* Queue of SSA_NAMEs to be freed at the next opportunity. */ |
90 | vec<tree, va_gc> *free_ssanames_queue; | |
91 | ||
cc524fc7 AM |
92 | /* Hashtable holding definition for symbol. If this field is not NULL, it |
93 | means that the first reference to this variable in the function is a | |
94 | USE or a VUSE. In those cases, the SSA renamer creates an SSA name | |
95 | for this variable with an empty defining statement. */ | |
2a22f99c | 96 | hash_table<ssa_name_hasher> *default_defs; |
cc524fc7 AM |
97 | |
98 | /* True if there are any symbols that need to be renamed. */ | |
99 | unsigned int ssa_renaming_needed : 1; | |
100 | ||
101 | /* True if all virtual operands need to be renamed. */ | |
102 | unsigned int rename_vops : 1; | |
103 | ||
104 | /* True if the code is in ssa form. */ | |
105 | unsigned int in_ssa_p : 1; | |
106 | ||
107 | /* True if IPA points-to information was computed for this function. */ | |
108 | unsigned int ipa_pta : 1; | |
109 | ||
110 | struct ssa_operands ssa_operands; | |
111 | ||
112 | /* Map gimple stmt to tree label (or list of labels) for transaction | |
113 | restart and abort. */ | |
50979347 | 114 | hash_table<tm_restart_hasher> *tm_restart; |
cc524fc7 AM |
115 | }; |
116 | ||
117 | ||
118 | /* Return true when gimple SSA form was built. | |
119 | gimple_in_ssa_p is queried by gimplifier in various early stages before SSA | |
120 | infrastructure is initialized. Check for presence of the datastructures | |
121 | at first place. */ | |
122 | static inline bool | |
123 | gimple_in_ssa_p (const struct function *fun) | |
124 | { | |
125 | return fun && fun->gimple_df && fun->gimple_df->in_ssa_p; | |
126 | } | |
127 | ||
cc524fc7 AM |
128 | /* Artificial variable used for the virtual operand FUD chain. */ |
129 | static inline tree | |
130 | gimple_vop (const struct function *fun) | |
131 | { | |
132 | gcc_checking_assert (fun && fun->gimple_df); | |
133 | return fun->gimple_df->vop; | |
134 | } | |
135 | ||
80560f95 AM |
136 | /* Return the set of VUSE operand for statement G. */ |
137 | ||
138 | static inline use_operand_p | |
355fe088 | 139 | gimple_vuse_op (const gimple *g) |
80560f95 AM |
140 | { |
141 | struct use_optype_d *ops; | |
daa6e488 | 142 | const gimple_statement_with_memory_ops *mem_ops_stmt = |
7de90a6c | 143 | dyn_cast <const gimple_statement_with_memory_ops *> (g); |
daa6e488 | 144 | if (!mem_ops_stmt) |
80560f95 | 145 | return NULL_USE_OPERAND_P; |
daa6e488 | 146 | ops = mem_ops_stmt->use_ops; |
80560f95 | 147 | if (ops |
daa6e488 | 148 | && USE_OP_PTR (ops)->use == &mem_ops_stmt->vuse) |
80560f95 AM |
149 | return USE_OP_PTR (ops); |
150 | return NULL_USE_OPERAND_P; | |
151 | } | |
152 | ||
153 | /* Return the set of VDEF operand for statement G. */ | |
154 | ||
155 | static inline def_operand_p | |
355fe088 | 156 | gimple_vdef_op (gimple *g) |
80560f95 | 157 | { |
daa6e488 | 158 | gimple_statement_with_memory_ops *mem_ops_stmt = |
7de90a6c | 159 | dyn_cast <gimple_statement_with_memory_ops *> (g); |
daa6e488 | 160 | if (!mem_ops_stmt) |
80560f95 | 161 | return NULL_DEF_OPERAND_P; |
daa6e488 DM |
162 | if (mem_ops_stmt->vdef) |
163 | return &mem_ops_stmt->vdef; | |
80560f95 AM |
164 | return NULL_DEF_OPERAND_P; |
165 | } | |
166 | ||
167 | /* Mark statement S as modified, and update it. */ | |
168 | ||
169 | static inline void | |
355fe088 | 170 | update_stmt (gimple *s) |
80560f95 AM |
171 | { |
172 | if (gimple_has_ops (s)) | |
173 | { | |
174 | gimple_set_modified (s, true); | |
6a58ccca | 175 | update_stmt_operands (cfun, s); |
80560f95 AM |
176 | } |
177 | } | |
178 | ||
179 | /* Update statement S if it has been optimized. */ | |
180 | ||
181 | static inline void | |
355fe088 | 182 | update_stmt_if_modified (gimple *s) |
80560f95 AM |
183 | { |
184 | if (gimple_modified_p (s)) | |
6a58ccca RB |
185 | update_stmt_operands (cfun, s); |
186 | } | |
187 | ||
188 | /* Mark statement S as modified, and update it. */ | |
189 | ||
190 | static inline void | |
355fe088 | 191 | update_stmt_fn (struct function *fn, gimple *s) |
6a58ccca RB |
192 | { |
193 | if (gimple_has_ops (s)) | |
194 | { | |
195 | gimple_set_modified (s, true); | |
196 | update_stmt_operands (fn, s); | |
197 | } | |
80560f95 AM |
198 | } |
199 | ||
200 | ||
201 | #endif /* GCC_GIMPLE_SSA_H */ |