hppa: Fix LO_SUM DLTIND14R address support in PRINT_OPERAND_ADDRESS
[official-gcc.git] / gcc / gimple-fold.h
blob182561b813292d0a63ed34a6422538034c0fb84d
1 /* Gimple folding definitions.
3 Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 Contributed by Richard Guenther <rguenther@suse.de>
6 This file is part of GCC.
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.
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.
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/>. */
22 #ifndef GCC_GIMPLE_FOLD_H
23 #define GCC_GIMPLE_FOLD_H
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 *);
33 extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree));
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);
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 gimple_build (gimple_seq *seq, location_t loc,
84 enum tree_code code, tree type, Args ...ops)
86 static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
87 "Number of operands must be from one to three");
88 gimple_stmt_iterator gsi = gsi_last (*seq);
89 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
90 loc, code, type, ops...);
92 template<class ...Args>
93 inline tree
94 gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops)
96 static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
97 "Number of operands must be from one to three");
98 gimple_stmt_iterator gsi = gsi_last (*seq);
99 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
100 UNKNOWN_LOCATION, code, type, ops...);
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 gimple_build (gimple_seq *seq, location_t loc,
118 combined_fn fn, tree type, Args ...args)
120 static_assert (sizeof...(args) < 4,
121 "Number of arguments must be less than four");
122 gimple_stmt_iterator gsi = gsi_last (*seq);
123 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
124 loc, fn, type, args...);
126 template<class ...Args>
127 inline tree
128 gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args)
130 static_assert (sizeof...(args) < 4,
131 "Number of arguments must be less than four");
132 gimple_stmt_iterator gsi = gsi_last (*seq);
133 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
134 UNKNOWN_LOCATION, fn, type, args...);
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);
147 template<class ...Args>
148 inline tree
149 gimple_build (gimple_seq *seq, location_t loc,
150 code_helper code, tree type, Args ...ops)
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...);
158 template<class ...Args>
159 inline tree
160 gimple_build (gimple_seq *seq,
161 code_helper code, tree type, Args ...ops)
163 static_assert (sizeof...(ops) < 4,
164 "Number of operands must be less than four");
165 gimple_stmt_iterator gsi = gsi_last (*seq);
166 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
167 UNKNOWN_LOCATION, code, type, ops...);
170 extern tree gimple_convert (gimple_stmt_iterator *, bool,
171 enum gsi_iterator_update,
172 location_t, tree, tree);
173 inline tree
174 gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
176 gimple_stmt_iterator gsi = gsi_last (*seq);
177 return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING, loc, type, op);
179 inline tree
180 gimple_convert (gimple_seq *seq, tree type, tree op)
182 gimple_stmt_iterator gsi = gsi_last (*seq);
183 return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING,
184 UNKNOWN_LOCATION, type, op);
187 extern tree gimple_convert_to_ptrofftype (gimple_stmt_iterator *, bool,
188 enum gsi_iterator_update,
189 location_t, tree);
190 inline tree
191 gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op)
193 gimple_stmt_iterator gsi = gsi_last (*seq);
194 return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
195 loc, op);
197 inline tree
198 gimple_convert_to_ptrofftype (gimple_seq *seq, tree op)
200 gimple_stmt_iterator gsi = gsi_last (*seq);
201 return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
202 UNKNOWN_LOCATION, op);
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 gimple_build_vector_from_val (gimple_seq *seq, location_t loc,
210 tree type, tree op)
212 gimple_stmt_iterator gsi = gsi_last (*seq);
213 return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
214 loc, type, op);
216 inline tree
217 gimple_build_vector_from_val (gimple_seq *seq, tree type, tree op)
219 gimple_stmt_iterator gsi = gsi_last (*seq);
220 return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
221 UNKNOWN_LOCATION, type, op);
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)
232 gimple_stmt_iterator gsi = gsi_last (*seq);
233 return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
234 loc, builder);
236 inline tree
237 gimple_build_vector (gimple_seq *seq, tree_vector_builder *builder)
239 gimple_stmt_iterator gsi = gsi_last (*seq);
240 return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
241 UNKNOWN_LOCATION, builder);
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 gimple_build_round_up (gimple_seq *seq, location_t loc,
250 tree type, tree old_size, unsigned HOST_WIDE_INT align)
252 gimple_stmt_iterator gsi = gsi_last (*seq);
253 return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
254 loc, type, old_size, align);
256 inline tree
257 gimple_build_round_up (gimple_seq *seq, tree type, tree old_size,
258 unsigned HOST_WIDE_INT align)
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);
265 extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
266 extern bool gimple_stmt_integer_valued_real_p (gimple *, int = 0);
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));
282 #endif /* GCC_GIMPLE_FOLD_H */