Branch data Line data Source code
1 : : /* Gimple folding definitions.
2 : :
3 : : Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 : : Contributed by Richard Guenther <rguenther@suse.de>
5 : :
6 : : This file is part of GCC.
7 : :
8 : : GCC is free software; you can redistribute it and/or modify it under
9 : : the terms of the GNU General Public License as published by the Free
10 : : Software Foundation; either version 3, or (at your option) any later
11 : : version.
12 : :
13 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 : : for more details.
17 : :
18 : : You should have received a copy of the GNU General Public License
19 : : along with GCC; see the file COPYING3. If not see
20 : : <http://www.gnu.org/licenses/>. */
21 : :
22 : : #ifndef GCC_GIMPLE_FOLD_H
23 : : #define GCC_GIMPLE_FOLD_H
24 : :
25 : : extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL);
26 : : extern tree canonicalize_constructor_val (tree, tree);
27 : : extern tree get_symbol_constant_value (tree);
28 : : struct c_strlen_data;
29 : : extern bool get_range_strlen (tree, c_strlen_data *, unsigned eltsize);
30 : : extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
31 : : extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
32 : : extern bool fold_stmt (gimple_stmt_iterator *, bitmap = nullptr);
33 : : extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree), bitmap = nullptr);
34 : : extern bool fold_stmt_inplace (gimple_stmt_iterator *);
35 : : extern tree maybe_fold_and_comparisons (tree, enum tree_code, tree, tree,
36 : : enum tree_code, tree, tree,
37 : : basic_block = nullptr);
38 : : extern tree maybe_fold_or_comparisons (tree, enum tree_code, tree, tree,
39 : : enum tree_code, tree, tree,
40 : : basic_block = nullptr);
41 : : extern bool optimize_atomic_compare_exchange_p (gimple *);
42 : : extern void fold_builtin_atomic_compare_exchange (gimple_stmt_iterator *);
43 : : extern tree no_follow_ssa_edges (tree);
44 : : extern tree follow_single_use_edges (tree);
45 : : extern tree follow_all_ssa_edges (tree);
46 : : extern tree gimple_fold_stmt_to_constant_1 (gimple *, tree (*) (tree),
47 : : tree (*) (tree) = no_follow_ssa_edges);
48 : : extern tree gimple_fold_stmt_to_constant (gimple *, tree (*) (tree));
49 : : extern tree fold_ctor_reference (tree, tree, const poly_uint64&,
50 : : const poly_uint64&, tree,
51 : : unsigned HOST_WIDE_INT * = NULL);
52 : : extern tree fold_const_aggregate_ref_1 (tree, tree (*) (tree));
53 : : extern tree fold_const_aggregate_ref (tree);
54 : : extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree,
55 : : bool *can_refer = NULL);
56 : : extern tree gimple_get_virt_method_for_vtable (HOST_WIDE_INT, tree,
57 : : unsigned HOST_WIDE_INT,
58 : : bool *can_refer = NULL);
59 : : extern tree gimple_fold_indirect_ref (tree);
60 : : extern bool gimple_fold_builtin_sprintf (gimple_stmt_iterator *);
61 : : extern bool gimple_fold_builtin_snprintf (gimple_stmt_iterator *);
62 : : extern bool arith_code_with_undefined_signed_overflow (tree_code);
63 : : extern void rewrite_to_defined_overflow (gimple_stmt_iterator *);
64 : : extern gimple_seq rewrite_to_defined_overflow (gimple *);
65 : : extern void replace_call_with_value (gimple_stmt_iterator *, tree);
66 : : extern tree tree_vec_extract (gimple_stmt_iterator *, tree, tree, tree, tree);
67 : : extern void gsi_replace_with_seq_vops (gimple_stmt_iterator *, gimple_seq);
68 : :
69 : : /* gimple_build, functionally matching fold_buildN, outputs stmts
70 : : int the provided sequence, matching and simplifying them on-the-fly.
71 : : Supposed to replace force_gimple_operand (fold_buildN (...), ...). */
72 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
73 : : enum gsi_iterator_update,
74 : : location_t, enum tree_code, tree, tree);
75 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
76 : : enum gsi_iterator_update,
77 : : location_t, enum tree_code, tree, tree, tree);
78 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
79 : : enum gsi_iterator_update,
80 : : location_t, enum tree_code, tree, tree, tree, tree);
81 : : template<class ...Args>
82 : : inline tree
83 : 515002 : gimple_build (gimple_seq *seq, location_t loc,
84 : : enum tree_code code, tree type, Args ...ops)
85 : : {
86 : : static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
87 : : "Number of operands must be from one to three");
88 : 515002 : gimple_stmt_iterator gsi = gsi_last (*seq);
89 : 515002 : return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
90 : 515002 : loc, code, type, ops...);
91 : : }
92 : : template<class ...Args>
93 : : inline tree
94 : 337840 : gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops)
95 : : {
96 : : static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
97 : : "Number of operands must be from one to three");
98 : 337840 : gimple_stmt_iterator gsi = gsi_last (*seq);
99 : 337840 : return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
100 : 337840 : UNKNOWN_LOCATION, code, type, ops...);
101 : : }
102 : :
103 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
104 : : enum gsi_iterator_update,
105 : : location_t, combined_fn, tree);
106 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
107 : : enum gsi_iterator_update,
108 : : location_t, combined_fn, tree, tree);
109 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
110 : : enum gsi_iterator_update,
111 : : location_t, combined_fn, tree, tree, tree);
112 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
113 : : enum gsi_iterator_update,
114 : : location_t, combined_fn, tree, tree, tree, tree);
115 : : template<class ...Args>
116 : : inline tree
117 : 385 : gimple_build (gimple_seq *seq, location_t loc,
118 : : combined_fn fn, tree type, Args ...args)
119 : : {
120 : : static_assert (sizeof...(args) < 4,
121 : : "Number of arguments must be less than four");
122 : 385 : gimple_stmt_iterator gsi = gsi_last (*seq);
123 : 385 : return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
124 : 385 : loc, fn, type, args...);
125 : : }
126 : : template<class ...Args>
127 : : inline tree
128 : 19928 : gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args)
129 : : {
130 : : static_assert (sizeof...(args) < 4,
131 : : "Number of arguments must be less than four");
132 : 19928 : gimple_stmt_iterator gsi = gsi_last (*seq);
133 : 19928 : return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
134 : 19928 : UNKNOWN_LOCATION, fn, type, args...);
135 : : }
136 : :
137 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
138 : : enum gsi_iterator_update,
139 : : location_t, code_helper, tree, tree);
140 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
141 : : enum gsi_iterator_update,
142 : : location_t, code_helper, tree, tree, tree);
143 : : extern tree gimple_build (gimple_stmt_iterator *, bool,
144 : : enum gsi_iterator_update,
145 : : location_t, code_helper, tree, tree, tree, tree);
146 : :
147 : : template<class ...Args>
148 : : inline tree
149 : : gimple_build (gimple_seq *seq, location_t loc,
150 : : code_helper code, tree type, Args ...ops)
151 : : {
152 : : static_assert (sizeof...(ops) < 4,
153 : : "Number of operands must be less than four");
154 : : gimple_stmt_iterator gsi = gsi_last (*seq);
155 : : return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
156 : : loc, code, type, ops...);
157 : : }
158 : : template<class ...Args>
159 : : inline tree
160 : 7144 : gimple_build (gimple_seq *seq,
161 : : code_helper code, tree type, Args ...ops)
162 : : {
163 : : static_assert (sizeof...(ops) < 4,
164 : : "Number of operands must be less than four");
165 : 7144 : gimple_stmt_iterator gsi = gsi_last (*seq);
166 : 7144 : return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
167 : 7144 : UNKNOWN_LOCATION, code, type, ops...);
168 : : }
169 : :
170 : : extern tree gimple_convert (gimple_stmt_iterator *, bool,
171 : : enum gsi_iterator_update,
172 : : location_t, tree, tree);
173 : : inline tree
174 : 10396 : gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
175 : : {
176 : 10396 : gimple_stmt_iterator gsi = gsi_last (*seq);
177 : 10396 : return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING, loc, type, op);
178 : : }
179 : : inline tree
180 : 1677480 : gimple_convert (gimple_seq *seq, tree type, tree op)
181 : : {
182 : 1677480 : gimple_stmt_iterator gsi = gsi_last (*seq);
183 : 1677480 : return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING,
184 : 1677480 : UNKNOWN_LOCATION, type, op);
185 : : }
186 : :
187 : : extern tree gimple_convert_to_ptrofftype (gimple_stmt_iterator *, bool,
188 : : enum gsi_iterator_update,
189 : : location_t, tree);
190 : : inline tree
191 : 203 : gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op)
192 : : {
193 : 203 : gimple_stmt_iterator gsi = gsi_last (*seq);
194 : 203 : return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
195 : 203 : loc, op);
196 : : }
197 : : inline tree
198 : : gimple_convert_to_ptrofftype (gimple_seq *seq, tree op)
199 : : {
200 : : gimple_stmt_iterator gsi = gsi_last (*seq);
201 : : return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
202 : : UNKNOWN_LOCATION, op);
203 : : }
204 : :
205 : : extern tree gimple_build_vector_from_val (gimple_stmt_iterator *, bool,
206 : : enum gsi_iterator_update,
207 : : location_t, tree, tree);
208 : : inline tree
209 : 321 : gimple_build_vector_from_val (gimple_seq *seq, location_t loc,
210 : : tree type, tree op)
211 : : {
212 : 321 : gimple_stmt_iterator gsi = gsi_last (*seq);
213 : 321 : return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
214 : 321 : loc, type, op);
215 : : }
216 : : inline tree
217 : 274924 : gimple_build_vector_from_val (gimple_seq *seq, tree type, tree op)
218 : : {
219 : 274924 : gimple_stmt_iterator gsi = gsi_last (*seq);
220 : 274924 : return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
221 : 274924 : UNKNOWN_LOCATION, type, op);
222 : : }
223 : :
224 : : class tree_vector_builder;
225 : : extern tree gimple_build_vector (gimple_stmt_iterator *, bool,
226 : : enum gsi_iterator_update,
227 : : location_t, tree_vector_builder *);
228 : : inline tree
229 : : gimple_build_vector (gimple_seq *seq, location_t loc,
230 : : tree_vector_builder *builder)
231 : : {
232 : : gimple_stmt_iterator gsi = gsi_last (*seq);
233 : : return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
234 : : loc, builder);
235 : : }
236 : : inline tree
237 : 326111 : gimple_build_vector (gimple_seq *seq, tree_vector_builder *builder)
238 : : {
239 : 326111 : gimple_stmt_iterator gsi = gsi_last (*seq);
240 : 326111 : return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
241 : 326111 : UNKNOWN_LOCATION, builder);
242 : : }
243 : :
244 : : extern tree gimple_build_round_up (gimple_stmt_iterator *, bool,
245 : : enum gsi_iterator_update,
246 : : location_t, tree, tree,
247 : : unsigned HOST_WIDE_INT);
248 : : inline tree
249 : 0 : gimple_build_round_up (gimple_seq *seq, location_t loc,
250 : : tree type, tree old_size, unsigned HOST_WIDE_INT align)
251 : : {
252 : 0 : gimple_stmt_iterator gsi = gsi_last (*seq);
253 : 0 : return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
254 : 0 : loc, type, old_size, align);
255 : : }
256 : : inline tree
257 : : gimple_build_round_up (gimple_seq *seq, tree type, tree old_size,
258 : : unsigned HOST_WIDE_INT align)
259 : : {
260 : : gimple_stmt_iterator gsi = gsi_last (*seq);
261 : : return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
262 : : UNKNOWN_LOCATION, type, old_size, align);
263 : : }
264 : :
265 : : extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
266 : : extern bool gimple_stmt_integer_valued_real_p (gimple *, int = 0);
267 : :
268 : : /* In gimple-match.cc. */
269 : : extern tree gimple_simplify (enum tree_code, tree, tree,
270 : : gimple_seq *, tree (*)(tree));
271 : : extern tree gimple_simplify (enum tree_code, tree, tree, tree,
272 : : gimple_seq *, tree (*)(tree));
273 : : extern tree gimple_simplify (enum tree_code, tree, tree, tree, tree,
274 : : gimple_seq *, tree (*)(tree));
275 : : extern tree gimple_simplify (combined_fn, tree, tree,
276 : : gimple_seq *, tree (*)(tree));
277 : : extern tree gimple_simplify (combined_fn, tree, tree, tree,
278 : : gimple_seq *, tree (*)(tree));
279 : : extern tree gimple_simplify (combined_fn, tree, tree, tree, tree,
280 : : gimple_seq *, tree (*)(tree));
281 : :
282 : : #endif /* GCC_GIMPLE_FOLD_H */
|