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 *);
33extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree));
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);
55 bool *can_refer = NULL);
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 (...), ...). */
81template<class ...Args>
82inline tree
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
115template<class ...Args>
116inline tree
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
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
146
147template<class ...Args>
148inline tree
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
173inline tree
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
190inline tree
192{
193 gimple_stmt_iterator gsi = gsi_last (*seq);
195 loc, op);
196}
197inline tree
204
208inline tree
210 tree type, tree op)
211{
212 gimple_stmt_iterator gsi = gsi_last (*seq);
214 loc, type, op);
215}
216inline tree
223
228inline tree
236inline tree
243
247 unsigned HOST_WIDE_INT);
248inline tree
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,
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
union tree_node * tree
Definition coretypes.h:97
combined_fn
Definition genmatch.cc:365
tree_code
Definition genmatch.cc:347
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
bool fold_stmt_inplace(gimple_stmt_iterator *)
Definition gimple-fold.cc:6540
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:8762
void rewrite_to_defined_overflow(gimple_stmt_iterator *)
Definition gimple-fold.cc:8836
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:3612
tree maybe_fold_and_comparisons(tree, enum tree_code, tree, tree, enum tree_code, tree, tree, basic_block=nullptr)
Definition gimple-fold.cc:7163
tree gimple_simplify(enum tree_code, tree, tree, gimple_seq *, tree(*)(tree))
Definition gimple-match-exports.cc:559
tree fold_ctor_reference(tree, tree, const poly_uint64 &, const poly_uint64 &, tree, unsigned HOST_WIDE_INT *=NULL)
Definition gimple-fold.cc:8226
tree gimple_fold_stmt_to_constant(gimple *, tree(*)(tree))
Definition gimple-fold.cc:7848
tree follow_single_use_edges(tree)
Definition gimple-fold.cc:6496
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:3482
bool gimple_stmt_nonnegative_warnv_p(gimple *, bool *, int=0)
Definition gimple-fold.cc:9373
tree maybe_fold_or_comparisons(tree, enum tree_code, tree, tree, enum tree_code, tree, tree, basic_block=nullptr)
Definition gimple-fold.cc:7515
tree gimple_get_virt_method_for_vtable(HOST_WIDE_INT, tree, unsigned HOST_WIDE_INT, bool *can_refer=NULL)
Definition gimple-fold.cc:8504
bool fold_stmt(gimple_stmt_iterator *)
Definition gimple-fold.cc:6520
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:7546
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:137
bool gimple_stmt_integer_valued_real_p(gimple *, int=0)
Definition gimple-fold.cc:9474
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:1969
tree fold_const_aggregate_ref_1(tree, tree(*)(tree))
Definition gimple-fold.cc:8326
tree canonicalize_constructor_val(tree, tree)
Definition gimple-fold.cc:212
tree follow_all_ssa_edges(tree)
Definition gimple-fold.cc:6507
tree gimple_get_virt_method_for_binfo(HOST_WIDE_INT, tree, bool *can_refer=NULL)
Definition gimple-fold.cc:8616
void replace_call_with_value(gimple_stmt_iterator *, tree)
Definition gimple-fold.cc:809
bool optimize_atomic_compare_exchange_p(gimple *)
Definition gimple-fold.cc:5283
tree no_follow_ssa_edges(tree)
Definition gimple-fold.cc:6488
void fold_builtin_atomic_compare_exchange(gimple_stmt_iterator *)
Definition gimple-fold.cc:5353
tree fold_const_aggregate_ref(tree)
Definition gimple-fold.cc:8492
tree gimple_fold_indirect_ref(tree)
Definition gimple-fold.cc:8643
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:225
Definition gengtype.h:252
#define NULL
Definition system.h:50