annotate gcc/gimple-ssa.h @ 158:494b0b89df80 default tip

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