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, ...);
31extern bool fold_stmt (gimple_stmt_iterator *, bitmap = nullptr);
32extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree), bitmap = nullptr);
35 enum tree_code, tree, tree,
36 basic_block = nullptr);
38 enum tree_code, tree, tree,
39 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);
67
68/* gimple_build, functionally matching fold_buildN, outputs stmts
69 int the provided sequence, matching and simplifying them on-the-fly.
70 Supposed to replace force_gimple_operand (fold_buildN (...), ...). */
73 location_t, enum tree_code, tree, tree);
76 location_t, enum tree_code, tree, tree, tree);
79 location_t, enum tree_code, tree, tree, tree, tree);
80template<class ...Args>
81inline tree
82gimple_build (gimple_seq *seq, location_t loc,
83 enum tree_code code, tree type, Args ...ops)
84{
85 static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
86 "Number of operands must be from one to three");
87 gimple_stmt_iterator gsi = gsi_last (*seq);
88 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
89 loc, code, type, ops...);
90}
91template<class ...Args>
92inline tree
93gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops)
94{
95 static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3,
96 "Number of operands must be from one to three");
97 gimple_stmt_iterator gsi = gsi_last (*seq);
98 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
99 UNKNOWN_LOCATION, code, type, ops...);
100}
101
104 location_t, combined_fn, tree);
107 location_t, combined_fn, tree, tree);
110 location_t, combined_fn, tree, tree, tree);
113 location_t, combined_fn, tree, tree, tree, tree);
114template<class ...Args>
115inline tree
116gimple_build (gimple_seq *seq, location_t loc,
117 combined_fn fn, tree type, Args ...args)
118{
119 static_assert (sizeof...(args) < 4,
120 "Number of arguments must be less than four");
121 gimple_stmt_iterator gsi = gsi_last (*seq);
122 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
123 loc, fn, type, args...);
124}
125template<class ...Args>
126inline tree
127gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args)
128{
129 static_assert (sizeof...(args) < 4,
130 "Number of arguments must be less than four");
131 gimple_stmt_iterator gsi = gsi_last (*seq);
132 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
133 UNKNOWN_LOCATION, fn, type, args...);
134}
135
138 location_t, code_helper, tree, tree);
141 location_t, code_helper, tree, tree, tree);
144 location_t, code_helper, tree, tree, tree, tree);
145
146template<class ...Args>
147inline tree
148gimple_build (gimple_seq *seq, location_t loc,
149 code_helper code, tree type, Args ...ops)
150{
151 static_assert (sizeof...(ops) < 4,
152 "Number of operands must be less than four");
153 gimple_stmt_iterator gsi = gsi_last (*seq);
154 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
155 loc, code, type, ops...);
156}
157template<class ...Args>
158inline tree
160 code_helper code, tree type, Args ...ops)
161{
162 static_assert (sizeof...(ops) < 4,
163 "Number of operands must be less than four");
164 gimple_stmt_iterator gsi = gsi_last (*seq);
165 return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
166 UNKNOWN_LOCATION, code, type, ops...);
167}
168
171 location_t, tree, tree);
172inline tree
173gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
174{
175 gimple_stmt_iterator gsi = gsi_last (*seq);
176 return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING, loc, type, op);
177}
178inline tree
180{
181 gimple_stmt_iterator gsi = gsi_last (*seq);
182 return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING,
184}
185
188 location_t, tree);
189inline tree
191{
192 gimple_stmt_iterator gsi = gsi_last (*seq);
194 loc, op);
195}
196inline tree
203
206 location_t, tree, tree);
207inline tree
209 tree type, tree op)
210{
211 gimple_stmt_iterator gsi = gsi_last (*seq);
213 loc, type, op);
214}
215inline tree
222
226 location_t, tree_vector_builder *);
227inline tree
228gimple_build_vector (gimple_seq *seq, location_t loc,
229 tree_vector_builder *builder)
230{
231 gimple_stmt_iterator gsi = gsi_last (*seq);
232 return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
233 loc, builder);
234}
235inline tree
237{
238 gimple_stmt_iterator gsi = gsi_last (*seq);
239 return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
240 UNKNOWN_LOCATION, builder);
241}
242
245 location_t, tree, tree,
246 unsigned HOST_WIDE_INT);
247inline tree
248gimple_build_round_up (gimple_seq *seq, location_t loc,
249 tree type, tree old_size, unsigned HOST_WIDE_INT align)
250{
251 gimple_stmt_iterator gsi = gsi_last (*seq);
252 return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
253 loc, type, old_size, align);
254}
255inline tree
257 unsigned HOST_WIDE_INT align)
258{
259 gimple_stmt_iterator gsi = gsi_last (*seq);
260 return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
261 UNKNOWN_LOCATION, type, old_size, align);
262}
263
264extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
265extern bool gimple_stmt_integer_valued_real_p (gimple *, int = 0);
267
268/* In gimple-match.cc. */
269extern tree gimple_simplify (enum tree_code, tree, tree,
270 gimple_seq *, tree (*)(tree));
272 gimple_seq *, tree (*)(tree));
274 gimple_seq *, tree (*)(tree));
276 gimple_seq *, tree (*)(tree));
278 gimple_seq *, tree (*)(tree));
280 gimple_seq *, tree (*)(tree));
281
282#endif /* GCC_GIMPLE_FOLD_H */
Definition tree.h:81
Definition tree-vector-builder.h:29
struct basic_block_def * basic_block
Definition coretypes.h:355
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
bool fold_stmt_inplace(gimple_stmt_iterator *)
Definition gimple-fold.cc:6765
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:10504
bool update_gimple_call(gimple_stmt_iterator *, tree, int,...)
Definition gimple-fold.cc:672
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:9945
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:11148
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:10224
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:11249
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:10045
void rewrite_to_defined_unconditional(gimple_stmt_iterator *)
Definition gimple-fold.cc:10611
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:10335
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:10212
tree gimple_fold_indirect_ref(tree)
Definition gimple-fold.cc:10362
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