GCC Middle and Back End API Reference
gimple-fold.h
Go to the documentation of this file.
1/* Gimple folding definitions.
2
3 Copyright (C) 2011-2025 Free Software Foundation, Inc.
4 Contributed by Richard Guenther <rguenther@suse.de>
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along 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
27struct c_strlen_data;
28extern bool get_range_strlen (tree, c_strlen_data *, unsigned eltsize);
30extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
34extern bool fold_stmt (gimple_stmt_iterator *, bitmap = nullptr);
35extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree), bitmap = nullptr);
38 enum tree_code, tree, tree,
39 basic_block = nullptr);
41 enum tree_code, tree, tree,
42 basic_block = nullptr);
49 const poly_uint64&, tree,
50 unsigned HOST_WIDE_INT * = NULL);
53extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree,
54 bool *can_refer = NULL);
55extern tree gimple_get_virt_method_for_vtable (HOST_WIDE_INT, tree,
56 unsigned HOST_WIDE_INT,
57 bool *can_refer = NULL);
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 (...), ...). */
74 location_t, enum tree_code, tree, tree);
77 location_t, enum tree_code, tree, tree, tree);
80 location_t, enum tree_code, tree, tree, tree, tree);
81template<class ...Args>
82inline tree
83gimple_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 gimple_stmt_iterator gsi = gsi_last (*seq);
89 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
90 loc, code, type, ops...);
91}
92template<class ...Args>
93inline tree
94gimple_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 gimple_stmt_iterator gsi = gsi_last (*seq);
99 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
100 UNKNOWN_LOCATION, code, type, ops...);
101}
102
105 location_t, combined_fn, tree);
108 location_t, combined_fn, tree, tree);
111 location_t, combined_fn, tree, tree, tree);
114 location_t, combined_fn, tree, tree, tree, tree);
115template<class ...Args>
116inline tree
117gimple_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 gimple_stmt_iterator gsi = gsi_last (*seq);
123 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
124 loc, fn, type, args...);
125}
126template<class ...Args>
127inline tree
128gimple_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 gimple_stmt_iterator gsi = gsi_last (*seq);
133 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
134 UNKNOWN_LOCATION, fn, type, args...);
135}
136
139 location_t, code_helper, tree, tree);
142 location_t, code_helper, tree, tree, tree);
145 location_t, code_helper, tree, tree, tree, tree);
146
147template<class ...Args>
148inline tree
149gimple_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}
158template<class ...Args>
159inline tree
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 gimple_stmt_iterator gsi = gsi_last (*seq);
166 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
167 UNKNOWN_LOCATION, code, type, ops...);
168}
169
172 location_t, tree, tree);
173inline tree
174gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
175{
176 gimple_stmt_iterator gsi = gsi_last (*seq);
177 return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING, loc, type, op);
178}
179inline tree
181{
182 gimple_stmt_iterator gsi = gsi_last (*seq);
183 return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING,
185}
186
189 location_t, tree);
190inline tree
192{
193 gimple_stmt_iterator gsi = gsi_last (*seq);
195 loc, op);
196}
197inline tree
204
207 location_t, tree, tree);
208inline tree
210 tree type, tree op)
211{
212 gimple_stmt_iterator gsi = gsi_last (*seq);
214 loc, type, op);
215}
216inline tree
223
227 location_t, tree_vector_builder *);
228inline tree
229gimple_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}
236inline tree
238{
239 gimple_stmt_iterator gsi = gsi_last (*seq);
240 return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
241 UNKNOWN_LOCATION, builder);
242}
243
246 location_t, tree, tree,
247 unsigned HOST_WIDE_INT);
248inline tree
249gimple_build_round_up (gimple_seq *seq, location_t loc,
250 tree type, tree old_size, unsigned HOST_WIDE_INT align)
251{
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);
255}
256inline tree
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
265extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
266extern bool gimple_stmt_integer_valued_real_p (gimple *, int = 0);
268
269/* In gimple-match.cc. */
270extern tree gimple_simplify (enum tree_code, tree, tree,
271 gimple_seq *, tree (*)(tree));
273 gimple_seq *, tree (*)(tree));
275 gimple_seq *, tree (*)(tree));
277 gimple_seq *, tree (*)(tree));
279 gimple_seq *, tree (*)(tree));
281 gimple_seq *, tree (*)(tree));
282
283#endif /* GCC_GIMPLE_FOLD_H */
Definition tree.h:82
Definition tree-vector-builder.h:29
struct basic_block_def * basic_block
Definition coretypes.h:357
gimple * gimple_seq
Definition coretypes.h:100
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
combined_fn
Definition genmatch.cc:1020
tree_code
Definition genmatch.cc:1002
tree no_follow_ssa_edges(tree)
Definition gimple-fold.cc:6713
tree get_symbol_constant_value(tree)
Definition gimple-fold.cc:272
void gsi_replace_with_seq_vops(gimple_stmt_iterator *, gimple_seq)
Definition gimple-fold.cc:582
tree gimple_convert_to_ptrofftype(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, tree)
void mark_lhs_in_seq_for_dce(bitmap, gimple_seq)
Definition gimple-fold.cc:6049
bool gimple_needing_rewrite_undefined(gimple *)
Definition gimple-fold.cc:10511
bool update_gimple_call(gimple_stmt_iterator *, tree, int,...)
Definition gimple-fold.cc:672
bool arith_code_with_undefined_signed_overflow(tree_code)
Definition gimple-fold.cc:10488
tree gimple_convert(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, tree, tree)
bool gimple_fold_builtin_snprintf(gimple_stmt_iterator *)
Definition gimple-fold.cc:3629
tree maybe_fold_and_comparisons(tree, enum tree_code, tree, tree, enum tree_code, tree, tree, basic_block=nullptr)
Definition gimple-fold.cc:8853
tree gimple_simplify(enum tree_code, tree, tree, gimple_seq *, tree(*)(tree))
Definition gimple-match-exports.cc:578
tree fold_ctor_reference(tree, tree, const poly_uint64 &, const poly_uint64 &, tree, unsigned HOST_WIDE_INT *=NULL)
Definition gimple-fold.cc:9952
tree gimple_fold_stmt_to_constant(gimple *, tree(*)(tree))
Definition gimple-fold.cc:9538
tree follow_single_use_edges(tree)
Definition gimple-fold.cc:6721
tree gimple_build_vector(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, tree_vector_builder *)
bool gimple_fold_builtin_sprintf(gimple_stmt_iterator *)
Definition gimple-fold.cc:3499
bool gimple_stmt_nonnegative_warnv_p(gimple *, bool *, int=0)
Definition gimple-fold.cc:11219
tree maybe_fold_or_comparisons(tree, enum tree_code, tree, tree, enum tree_code, tree, tree, basic_block=nullptr)
Definition gimple-fold.cc:9205
tree gimple_get_virt_method_for_vtable(HOST_WIDE_INT, tree, unsigned HOST_WIDE_INT, bool *can_refer=NULL)
Definition gimple-fold.cc:10231
void gimplify_and_update_call_from_tree(gimple_stmt_iterator *, tree)
Definition gimple-fold.cc:725
tree gimple_build_vector_from_val(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, tree, tree)
tree gimple_build_round_up(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, tree, tree, unsigned HOST_WIDE_INT)
tree gimple_fold_stmt_to_constant_1(gimple *, tree(*)(tree), tree(*)(tree)=no_follow_ssa_edges)
Definition gimple-fold.cc:9236
tree tree_vec_extract(gimple_stmt_iterator *, tree, tree, tree, tree)
Definition tree-vect-generic.cc:136
bool gimple_stmt_integer_valued_real_p(gimple *, int=0)
Definition gimple-fold.cc:11320
tree gimple_build(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, enum tree_code, tree, tree)
bool get_range_strlen(tree, c_strlen_data *, unsigned eltsize)
Definition gimple-fold.cc:1975
tree fold_const_aggregate_ref_1(tree, tree(*)(tree))
Definition gimple-fold.cc:10052
void rewrite_to_defined_unconditional(gimple_stmt_iterator *)
Definition gimple-fold.cc:10682
bool fold_stmt_inplace(gimple_stmt_iterator *, tree(*)(tree)=no_follow_ssa_edges)
Definition gimple-fold.cc:6765
bool fold_stmt(gimple_stmt_iterator *, bitmap=nullptr)
Definition gimple-fold.cc:6745
tree canonicalize_constructor_val(tree, tree)
Definition gimple-fold.cc:199
tree follow_all_ssa_edges(tree)
Definition gimple-fold.cc:6732
tree gimple_get_virt_method_for_binfo(HOST_WIDE_INT, tree, bool *can_refer=NULL)
Definition gimple-fold.cc:10342
void replace_call_with_value(gimple_stmt_iterator *, tree)
Definition gimple-fold.cc:805
bool optimize_atomic_compare_exchange_p(gimple *)
Definition gimple-fold.cc:5432
tree no_follow_ssa_edges(tree)
Definition gimple-fold.cc:6713
void fold_builtin_atomic_compare_exchange(gimple_stmt_iterator *)
Definition gimple-fold.cc:5502
tree fold_const_aggregate_ref(tree)
Definition gimple-fold.cc:10219
tree gimple_fold_indirect_ref(tree)
Definition gimple-fold.cc:10369
gimple_stmt_iterator gsi_last(gimple_seq &seq)
Definition gimple-iterator.h:148
gsi_iterator_update
Definition gimple-iterator.h:52
@ GSI_CONTINUE_LINKING
Definition gimple-iterator.h:56
#define UNKNOWN_LOCATION
Definition input.h:32
poly_int< NUM_POLY_INT_COEFFS, unsigned HOST_WIDE_INT > poly_uint64
Definition poly-int-types.h:25
Definition builtins.h:71
Definition gimple-iterator.h:26
Definition gimple.h:221
Definition gengtype.h:252
#define NULL
Definition system.h:50