111
|
1 /* Support routines for Value Range Propagation (VRP).
|
145
|
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
|
111
|
3
|
|
4 This file is part of GCC.
|
|
5
|
|
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
|
|
8 the Free Software Foundation; either version 3, or (at your option)
|
|
9 any later version.
|
|
10
|
|
11 GCC is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 GNU General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GCC; see the file COPYING3. If not see
|
|
18 <http://www.gnu.org/licenses/>. */
|
|
19
|
|
20 #ifndef GCC_TREE_VRP_H
|
|
21 #define GCC_TREE_VRP_H
|
|
22
|
145
|
23 #include "value-range.h"
|
111
|
24
|
145
|
25 /* Note value_range_equiv cannot currently be used with GC memory,
|
|
26 only value_range is fully set up for this. */
|
|
27 class GTY((user)) value_range_equiv : public value_range
|
111
|
28 {
|
131
|
29 public:
|
145
|
30 value_range_equiv ();
|
|
31 value_range_equiv (const value_range &);
|
|
32 /* Deep-copies equiv bitmap argument. */
|
|
33 value_range_equiv (tree, tree, bitmap = NULL, value_range_kind = VR_RANGE);
|
|
34
|
|
35 /* Shallow-copies equiv bitmap. */
|
|
36 value_range_equiv (const value_range_equiv &) /* = delete */;
|
|
37 /* Shallow-copies equiv bitmap. */
|
|
38 value_range_equiv& operator=(const value_range_equiv &) /* = delete */;
|
|
39
|
|
40 /* Move equiv bitmap from source range. */
|
|
41 void move (value_range_equiv *);
|
|
42
|
|
43 /* Leaves equiv bitmap alone. */
|
|
44 void update (tree, tree, value_range_kind = VR_RANGE);
|
|
45 /* Deep-copies equiv bitmap argument. */
|
|
46 void set (tree, tree, bitmap = NULL, value_range_kind = VR_RANGE);
|
|
47 void set (tree);
|
|
48
|
|
49 bool operator== (const value_range_equiv &) const /* = delete */;
|
|
50 bool operator!= (const value_range_equiv &) const /* = delete */;
|
|
51 void intersect (const value_range_equiv *);
|
|
52 void union_ (const value_range_equiv *);
|
|
53 bool equal_p (const value_range_equiv &, bool ignore_equivs) const;
|
111
|
54
|
131
|
55 /* Types of value ranges. */
|
|
56 void set_undefined ();
|
145
|
57 void set_varying (tree);
|
131
|
58
|
|
59 /* Equivalence bitmap methods. */
|
|
60 bitmap equiv () const;
|
|
61 void equiv_clear ();
|
145
|
62 void equiv_add (const_tree, const value_range_equiv *,
|
|
63 bitmap_obstack * = NULL);
|
111
|
64
|
131
|
65 /* Misc methods. */
|
145
|
66 void deep_copy (const value_range_equiv *);
|
131
|
67 void dump (FILE *) const;
|
|
68 void dump () const;
|
111
|
69
|
131
|
70 private:
|
145
|
71 /* Deep-copies bitmap argument. */
|
|
72 void set_equiv (bitmap);
|
131
|
73 void check ();
|
|
74
|
111
|
75 /* Set of SSA names whose value ranges are equivalent to this one.
|
|
76 This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */
|
131
|
77 bitmap m_equiv;
|
111
|
78 };
|
|
79
|
131
|
80 inline
|
145
|
81 value_range_equiv::value_range_equiv ()
|
|
82 : value_range ()
|
131
|
83 {
|
|
84 m_equiv = NULL;
|
|
85 }
|
|
86
|
|
87 inline bitmap
|
145
|
88 value_range_equiv::equiv () const
|
131
|
89 {
|
|
90 return m_equiv;
|
|
91 }
|
|
92
|
145
|
93 extern void dump_value_range (FILE *, const value_range_equiv *);
|
131
|
94
|
|
95 struct assert_info
|
|
96 {
|
|
97 /* Predicate code for the ASSERT_EXPR. Must be COMPARISON_CLASS_P. */
|
|
98 enum tree_code comp_code;
|
|
99
|
|
100 /* Name to register the assert for. */
|
|
101 tree name;
|
|
102
|
|
103 /* Value being compared against. */
|
|
104 tree val;
|
|
105
|
|
106 /* Expression to compare. */
|
|
107 tree expr;
|
|
108 };
|
|
109
|
|
110 extern void register_edge_assert_for (tree, edge, enum tree_code,
|
|
111 tree, tree, vec<assert_info> &);
|
|
112 extern bool stmt_interesting_for_vrp (gimple *);
|
|
113 extern bool infer_value_range (gimple *, tree, tree_code *, tree *);
|
|
114
|
145
|
115 extern bool range_int_cst_p (const value_range *);
|
|
116
|
131
|
117 extern int compare_values (tree, tree);
|
|
118 extern int compare_values_warnv (tree, tree, bool *);
|
|
119 extern int operand_less_p (tree, tree);
|
145
|
120
|
|
121 void range_fold_unary_expr (value_range *, enum tree_code, tree type,
|
|
122 const value_range *, tree op0_type);
|
|
123 void range_fold_binary_expr (value_range *, enum tree_code, tree type,
|
|
124 const value_range *, const value_range *);
|
|
125
|
|
126 extern enum value_range_kind intersect_range_with_nonzero_bits
|
|
127 (enum value_range_kind, wide_int *, wide_int *, const wide_int &, signop);
|
|
128
|
131
|
129 extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *);
|
|
130 extern bool find_case_label_index (gswitch *, size_t, tree, size_t *);
|
|
131 extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *);
|
|
132 extern tree get_single_symbol (tree, bool *, tree *);
|
|
133 extern void maybe_set_nonzero_bits (edge, tree);
|
|
134 extern value_range_kind determine_value_range (tree, wide_int *, wide_int *);
|
145
|
135
|
111
|
136 #endif /* GCC_TREE_VRP_H */
|