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-2024 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
28struct c_strlen_data;
29extern bool get_range_strlen (tree, c_strlen_data *, unsigned eltsize);
31extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
32extern bool fold_stmt (gimple_stmt_iterator *, bitmap = nullptr);
33extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree), bitmap = nullptr);
36 enum tree_code, tree, tree,
37 basic_block = nullptr);
39 enum tree_code, tree, tree,
40 basic_block = nullptr);
50 const poly_uint64&, tree,
51 unsigned HOST_WIDE_INT * = NULL);
54extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree,
55 bool *can_refer = NULL);
56extern tree gimple_get_virt_method_for_vtable (HOST_WIDE_INT, tree,
57 unsigned HOST_WIDE_INT,
58 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);
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
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
combined_fn
Definition genmatch.cc:1010
tree_code
Definition genmatch.cc:992
bool fold_stmt_inplace(gimple_stmt_iterator *)
Definition gimple-fold.cc:6827
tree get_symbol_constant_value(tree)
Definition gimple-fold.cc:285
void gsi_replace_with_seq_vops(gimple_stmt_iterator *, gimple_seq)
Definition gimple-fold.cc:595
tree gimple_convert_to_ptrofftype(gimple_stmt_iterator *, bool, enum gsi_iterator_update, location_t, tree)
bool update_gimple_call(gimple_stmt_iterator *, tree, int,...)
Definition gimple-fold.cc:685
bool arith_code_with_undefined_signed_overflow(tree_code)
Definition gimple-fold.cc:10245
void rewrite_to_defined_overflow(gimple_stmt_iterator *)
Definition gimple-fold.cc:10319
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:3768
tree maybe_fold_and_comparisons(tree, enum tree_code, tree, tree, enum tree_code, tree, tree, basic_block=nullptr)
Definition gimple-fold.cc:8616
tree gimple_simplify(enum tree_code, tree, tree, gimple_seq *, tree(*)(tree))
Definition gimple-match-exports.cc:572
tree fold_ctor_reference(tree, tree, const poly_uint64 &, const poly_uint64 &, tree, unsigned HOST_WIDE_INT *=NULL)
Definition gimple-fold.cc:9709
tree gimple_fold_stmt_to_constant(gimple *, tree(*)(tree))
Definition gimple-fold.cc:9301
tree follow_single_use_edges(tree)
Definition gimple-fold.cc:6783
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:3638
bool gimple_stmt_nonnegative_warnv_p(gimple *, bool *, int=0)
Definition gimple-fold.cc:10856
tree maybe_fold_or_comparisons(tree, enum tree_code, tree, tree, enum tree_code, tree, tree, basic_block=nullptr)
Definition gimple-fold.cc:8968
tree gimple_get_virt_method_for_vtable(HOST_WIDE_INT, tree, unsigned HOST_WIDE_INT, bool *can_refer=NULL)
Definition gimple-fold.cc:9987
void gimplify_and_update_call_from_tree(gimple_stmt_iterator *, tree)
Definition gimple-fold.cc:738
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:8999
tree create_tmp_reg_or_ssa_name(tree, gimple *stmt=NULL)
Definition gimple-fold.cc:199
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:10957
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:2114
tree fold_const_aggregate_ref_1(tree, tree(*)(tree))
Definition gimple-fold.cc:9809
bool fold_stmt(gimple_stmt_iterator *, bitmap=nullptr)
Definition gimple-fold.cc:6807
tree canonicalize_constructor_val(tree, tree)
Definition gimple-fold.cc:212
tree follow_all_ssa_edges(tree)
Definition gimple-fold.cc:6794
tree gimple_get_virt_method_for_binfo(HOST_WIDE_INT, tree, bool *can_refer=NULL)
Definition gimple-fold.cc:10099
void replace_call_with_value(gimple_stmt_iterator *, tree)
Definition gimple-fold.cc:818
bool optimize_atomic_compare_exchange_p(gimple *)
Definition gimple-fold.cc:5531
tree no_follow_ssa_edges(tree)
Definition gimple-fold.cc:6775
void fold_builtin_atomic_compare_exchange(gimple_stmt_iterator *)
Definition gimple-fold.cc:5601
tree fold_const_aggregate_ref(tree)
Definition gimple-fold.cc:9975
tree gimple_fold_indirect_ref(tree)
Definition gimple-fold.cc:10126
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
Definition basic-block.h:117
Definition builtins.h:71
Definition gimple-iterator.h:26
Definition gimple.h:221
Definition gengtype.h:252
#define NULL
Definition system.h:50