comparison gcc/tree-vrp.h @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Support routines for Value Range Propagation (VRP). 1 /* Support routines for Value Range Propagation (VRP).
2 Copyright (C) 2016-2017 Free Software Foundation, Inc. 2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify 6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
18 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
19 19
20 #ifndef GCC_TREE_VRP_H 20 #ifndef GCC_TREE_VRP_H
21 #define GCC_TREE_VRP_H 21 #define GCC_TREE_VRP_H
22 22
23 /* Type of value ranges. See value_range_d In tree-vrp.c for a 23 /* Types of value ranges. */
24 description of these types. */ 24 enum value_range_kind
25 enum value_range_type { VR_UNDEFINED, VR_RANGE, 25 {
26 VR_ANTI_RANGE, VR_VARYING, VR_LAST }; 26 /* Empty range. */
27 VR_UNDEFINED,
28 /* Range spans the entire domain. */
29 VR_VARYING,
30 /* Range is [MIN, MAX]. */
31 VR_RANGE,
32 /* Range is ~[MIN, MAX]. */
33 VR_ANTI_RANGE,
34 /* Range is a nice guy. */
35 VR_LAST
36 };
27 37
28 /* Range of values that can be associated with an SSA_NAME after VRP 38 /* Range of values that can be associated with an SSA_NAME after VRP
29 has executed. */ 39 has executed. */
30 struct GTY((for_user)) value_range 40 class GTY((for_user)) value_range
31 { 41 {
32 /* Lattice value represented by this range. */ 42 public:
33 enum value_range_type type; 43 value_range ();
34 44 value_range (value_range_kind, tree, tree, bitmap = NULL);
35 /* Minimum and maximum values represented by this range. These 45 void update (value_range_kind, tree, tree);
36 values should be interpreted as follows: 46 bool operator== (const value_range &) const;
37 47 bool operator!= (const value_range &) const;
38 - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must 48 void intersect (const value_range *);
39 be NULL. 49 void union_ (const value_range *);
40 50
41 - If TYPE == VR_RANGE then MIN holds the minimum value and 51 /* Types of value ranges. */
42 MAX holds the maximum value of the range [MIN, MAX]. 52 bool undefined_p () const;
43 53 bool varying_p () const;
44 - If TYPE == ANTI_RANGE the variable is known to NOT 54 bool symbolic_p () const;
45 take any values in the range [MIN, MAX]. */ 55 bool constant_p () const;
46 tree min; 56 void set_undefined ();
47 tree max; 57 void set_varying ();
48 58
59 /* Equivalence bitmap methods. */
60 bitmap equiv () const;
61 void equiv_clear ();
62 void equiv_add (const_tree, const value_range *, bitmap_obstack * = NULL);
63
64 /* Misc methods. */
65 tree type () const;
66 bool null_p () const;
67 bool may_contain_p (tree) const;
68 bool singleton_p (tree *result = NULL) const;
69 void deep_copy (const value_range *);
70 bool ignore_equivs_equal_p (const value_range &) const;
71 void set_and_canonicalize (enum value_range_kind, tree, tree, bitmap);
72 void dump (FILE *) const;
73 void dump () const;
74
75 enum value_range_kind kind () const;
76 tree min () const;
77 tree max () const;
78
79 private:
80 void set (value_range_kind, tree, tree, bitmap);
81 void check ();
82 bool equal_p (const value_range &, bool ignore_equivs) const;
83 void intersect_helper (value_range *, const value_range *);
84 void union_helper (value_range *, const value_range *);
85
86 enum value_range_kind m_kind;
87 public:
88 /* These should be private, but GTY is a piece of crap. */
89 tree m_min;
90 tree m_max;
49 /* Set of SSA names whose value ranges are equivalent to this one. 91 /* Set of SSA names whose value ranges are equivalent to this one.
50 This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */ 92 This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */
51 bitmap equiv; 93 bitmap m_equiv;
52 }; 94 };
53 95
54 extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1); 96 inline
55 extern void vrp_meet (value_range *vr0, const value_range *vr1); 97 value_range::value_range ()
98 {
99 m_kind = VR_UNDEFINED;
100 m_min = m_max = NULL;
101 m_equiv = NULL;
102 }
103
104 /* Return the kind of this range. */
105
106 inline value_range_kind
107 value_range::kind () const
108 {
109 return m_kind;
110 }
111
112 inline bitmap
113 value_range::equiv () const
114 {
115 return m_equiv;
116 }
117
118 /* Return the lower bound. */
119
120 inline tree
121 value_range::min () const
122 {
123 return m_min;
124 }
125
126 /* Return the upper bound. */
127
128 inline tree
129 value_range::max () const
130 {
131 return m_max;
132 }
133
134 /* Return TRUE if range spans the entire possible domain. */
135
136 inline bool
137 value_range::varying_p () const
138 {
139 return m_kind == VR_VARYING;
140 }
141
142 /* Return TRUE if range is undefined (essentially the empty set). */
143
144 inline bool
145 value_range::undefined_p () const
146 {
147 return m_kind == VR_UNDEFINED;
148 }
149
150 /* Return TRUE if range is the constant zero. */
151
152 inline bool
153 value_range::null_p () const
154 {
155 return (m_kind == VR_RANGE
156 && integer_zerop (m_min)
157 && integer_zerop (m_max));
158 }
159
56 extern void dump_value_range (FILE *, const value_range *); 160 extern void dump_value_range (FILE *, const value_range *);
57 extern void extract_range_from_unary_expr (value_range *vr, 161 extern void extract_range_from_unary_expr (value_range *vr,
58 enum tree_code code, 162 enum tree_code code,
59 tree type, 163 tree type,
60 value_range *vr0_, 164 const value_range *vr0_,
61 tree op0_type); 165 tree op0_type);
62 166
167 extern bool vrp_operand_equal_p (const_tree, const_tree);
168 extern enum value_range_kind intersect_range_with_nonzero_bits
169 (enum value_range_kind, wide_int *, wide_int *, const wide_int &, signop);
170
171 struct assert_info
172 {
173 /* Predicate code for the ASSERT_EXPR. Must be COMPARISON_CLASS_P. */
174 enum tree_code comp_code;
175
176 /* Name to register the assert for. */
177 tree name;
178
179 /* Value being compared against. */
180 tree val;
181
182 /* Expression to compare. */
183 tree expr;
184 };
185
186 extern void register_edge_assert_for (tree, edge, enum tree_code,
187 tree, tree, vec<assert_info> &);
188 extern bool stmt_interesting_for_vrp (gimple *);
189 extern void set_value_range_to_varying (value_range *);
190 extern bool range_includes_zero_p (const value_range *);
191 extern bool infer_value_range (gimple *, tree, tree_code *, tree *);
192
193 extern void set_value_range_to_nonnull (value_range *, tree);
194 extern void set_value_range (value_range *, enum value_range_kind, tree,
195 tree, bitmap);
196 extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap);
197 extern tree value_range_constant_singleton (const value_range *);
198 extern int compare_values (tree, tree);
199 extern int compare_values_warnv (tree, tree, bool *);
200 extern bool vrp_val_is_min (const_tree);
201 extern bool vrp_val_is_max (const_tree);
202 extern void set_value_range_to_value (value_range *, tree, bitmap);
203 extern void extract_range_from_binary_expr_1 (value_range *, enum tree_code,
204 tree, const value_range *,
205 const value_range *);
206 extern tree vrp_val_min (const_tree);
207 extern tree vrp_val_max (const_tree);
208 extern void set_value_range_to_null (value_range *, tree);
209 extern bool range_int_cst_p (const value_range *);
210 extern int operand_less_p (tree, tree);
211 extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *);
212 extern bool find_case_label_index (gswitch *, size_t, tree, size_t *);
213 extern bool vrp_set_zero_nonzero_bits (const tree, const value_range *,
214 wide_int *, wide_int *);
215 extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *);
216 extern bool range_int_cst_singleton_p (const value_range *);
217 extern int value_inside_range (tree, tree, tree);
218 extern tree get_single_symbol (tree, bool *, tree *);
219 extern void maybe_set_nonzero_bits (edge, tree);
220 extern value_range_kind determine_value_range (tree, wide_int *, wide_int *);
63 #endif /* GCC_TREE_VRP_H */ 221 #endif /* GCC_TREE_VRP_H */