1/* Gimple folding definitions.
2
3 Copyright (C) 2011-2017 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
25extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL);
26extern tree canonicalize_constructor_val (tree, tree);
27extern tree get_symbol_constant_value (tree);
28extern bool get_range_strlen (tree, tree[2]);
29extern tree get_maxval_strlen (tree, int);
30extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
31extern bool fold_stmt (gimple_stmt_iterator *);
32extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree));
33extern bool fold_stmt_inplace (gimple_stmt_iterator *);
34extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree,
35 enum tree_code, tree, tree);
36extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
37 enum tree_code, tree, tree);
38extern bool optimize_atomic_compare_exchange_p (gimple *);
39extern void fold_builtin_atomic_compare_exchange (gimple_stmt_iterator *);
40extern bool arith_overflowed_p (enum tree_code, const_tree, const_tree,
41 const_tree);
42extern tree no_follow_ssa_edges (tree);
43extern tree follow_single_use_edges (tree);
44extern tree gimple_fold_stmt_to_constant_1 (gimple *, tree (*) (tree),
45 tree (*) (tree) = no_follow_ssa_edges);
46extern tree gimple_fold_stmt_to_constant (gimple *, tree (*) (tree));
47extern tree fold_ctor_reference (tree, tree, unsigned HOST_WIDE_INT,
48 unsigned HOST_WIDE_INT, tree);
49extern tree fold_const_aggregate_ref_1 (tree, tree (*) (tree));
50extern tree fold_const_aggregate_ref (tree);
51extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree,
52 bool *can_refer = NULL);
53extern tree gimple_get_virt_method_for_vtable (HOST_WIDE_INT, tree,
54 unsigned HOST_WIDE_INT,
55 bool *can_refer = NULL);
56extern tree gimple_fold_indirect_ref (tree);
57extern bool gimple_fold_builtin_sprintf (gimple_stmt_iterator *);
58extern bool gimple_fold_builtin_snprintf (gimple_stmt_iterator *);
59extern bool arith_code_with_undefined_signed_overflow (tree_code);
60extern gimple_seq rewrite_to_defined_overflow (gimple *);
61extern void replace_call_with_value (gimple_stmt_iterator *, tree);
62
63/* gimple_build, functionally matching fold_buildN, outputs stmts
64 int the provided sequence, matching and simplifying them on-the-fly.
65 Supposed to replace force_gimple_operand (fold_buildN (...), ...). */
66extern tree gimple_build (gimple_seq *, location_t,
67 enum tree_code, tree, tree);
68inline tree
69gimple_build (gimple_seq *seq,
70 enum tree_code code, tree type, tree op0)
71{
72 return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0);
73}
74extern tree gimple_build (gimple_seq *, location_t,
75 enum tree_code, tree, tree, tree);
76inline tree
77gimple_build (gimple_seq *seq,
78 enum tree_code code, tree type, tree op0, tree op1)
79{
80 return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1);
81}
82extern tree gimple_build (gimple_seq *, location_t,
83 enum tree_code, tree, tree, tree, tree);
84inline tree
85gimple_build (gimple_seq *seq,
86 enum tree_code code, tree type, tree op0, tree op1, tree op2)
87{
88 return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2);
89}
90extern tree gimple_build (gimple_seq *, location_t,
91 enum built_in_function, tree, tree);
92inline tree
93gimple_build (gimple_seq *seq,
94 enum built_in_function fn, tree type, tree arg0)
95{
96 return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0);
97}
98extern tree gimple_build (gimple_seq *, location_t,
99 enum built_in_function, tree, tree, tree);
100inline tree
101gimple_build (gimple_seq *seq,
102 enum built_in_function fn, tree type, tree arg0, tree arg1)
103{
104 return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1);
105}
106extern tree gimple_build (gimple_seq *, location_t,
107 enum built_in_function, tree, tree, tree, tree);
108inline tree
109gimple_build (gimple_seq *seq,
110 enum built_in_function fn, tree type,
111 tree arg0, tree arg1, tree arg2)
112{
113 return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1, arg2);
114}
115
116extern tree gimple_convert (gimple_seq *, location_t, tree, tree);
117inline tree
118gimple_convert (gimple_seq *seq, tree type, tree op)
119{
120 return gimple_convert (seq, UNKNOWN_LOCATION, type, op);
121}
122
123extern tree gimple_convert_to_ptrofftype (gimple_seq *, location_t, tree);
124inline tree
125gimple_convert_to_ptrofftype (gimple_seq *seq, tree op)
126{
127 return gimple_convert_to_ptrofftype (seq, UNKNOWN_LOCATION, op);
128}
129
130extern tree gimple_build_vector_from_val (gimple_seq *, location_t, tree,
131 tree);
132inline tree
133gimple_build_vector_from_val (gimple_seq *seq, tree type, tree op)
134{
135 return gimple_build_vector_from_val (seq, UNKNOWN_LOCATION, type, op);
136}
137
138class tree_vector_builder;
139extern tree gimple_build_vector (gimple_seq *, location_t,
140 tree_vector_builder *);
141inline tree
142gimple_build_vector (gimple_seq *seq, tree_vector_builder *builder)
143{
144 return gimple_build_vector (seq, UNKNOWN_LOCATION, builder);
145}
146
147extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
148extern bool gimple_stmt_integer_valued_real_p (gimple *, int = 0);
149
150/* In gimple-match.c. */
151extern tree gimple_simplify (enum tree_code, tree, tree,
152 gimple_seq *, tree (*)(tree));
153extern tree gimple_simplify (enum tree_code, tree, tree, tree,
154 gimple_seq *, tree (*)(tree));
155extern tree gimple_simplify (enum tree_code, tree, tree, tree, tree,
156 gimple_seq *, tree (*)(tree));
157extern tree gimple_simplify (enum built_in_function, tree, tree,
158 gimple_seq *, tree (*)(tree));
159extern tree gimple_simplify (enum built_in_function, tree, tree, tree,
160 gimple_seq *, tree (*)(tree));
161extern tree gimple_simplify (enum built_in_function, tree, tree, tree, tree,
162 gimple_seq *, tree (*)(tree));
163
164#endif /* GCC_GIMPLE_FOLD_H */
165