vr-values.c: New file with contents extracted from tree-vrp.c.
[platform/upstream/gcc.git] / gcc / tree-vrp.h
1 /* Support routines for Value Range Propagation (VRP).
2    Copyright (C) 2016-2017 Free Software Foundation, Inc.
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
23 /* Type of value ranges.  See value_range below for a
24    description of these types.  */
25 enum value_range_type { VR_UNDEFINED, VR_RANGE,
26                         VR_ANTI_RANGE, VR_VARYING, VR_LAST };
27
28 /* Range of values that can be associated with an SSA_NAME after VRP
29    has executed.  */
30 struct GTY((for_user)) value_range
31 {
32   /* Lattice value represented by this range.  */
33   enum value_range_type type;
34
35   /* Minimum and maximum values represented by this range.  These
36      values should be interpreted as follows:
37
38         - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must
39           be NULL.
40
41         - If TYPE == VR_RANGE then MIN holds the minimum value and
42           MAX holds the maximum value of the range [MIN, MAX].
43
44         - If TYPE == ANTI_RANGE the variable is known to NOT
45           take any values in the range [MIN, MAX].  */
46   tree min;
47   tree max;
48
49   /* 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.  */
51   bitmap equiv;
52 };
53
54 extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1);
55 extern void vrp_meet (value_range *vr0, const value_range *vr1);
56 extern void dump_value_range (FILE *, const value_range *);
57 extern void extract_range_from_unary_expr (value_range *vr,
58                                            enum tree_code code,
59                                            tree type,
60                                            value_range *vr0_,
61                                            tree op0_type);
62
63 extern bool vrp_operand_equal_p (const_tree, const_tree);
64
65 struct assert_info
66 {
67   /* Predicate code for the ASSERT_EXPR.  Must be COMPARISON_CLASS_P.  */
68   enum tree_code comp_code;
69
70   /* Name to register the assert for.  */
71   tree name;
72
73   /* Value being compared against.  */
74   tree val;
75
76   /* Expression to compare.  */
77   tree expr;
78 };
79
80 extern void register_edge_assert_for (tree, edge, enum tree_code,
81                                       tree, tree, vec<assert_info> &);
82 extern bool stmt_interesting_for_vrp (gimple *);
83 extern void set_value_range_to_varying (value_range *);
84 extern int range_includes_zero_p (tree, tree);
85 extern bool infer_value_range (gimple *, tree, tree_code *, tree *);
86
87 extern void set_value_range_to_nonnull (value_range *, tree);
88 extern void set_value_range (value_range *, enum value_range_type, tree,
89                              tree, bitmap);
90 extern void set_and_canonicalize_value_range (value_range *,
91                                               enum value_range_type,
92                                               tree, tree, bitmap);
93 extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap);
94 extern bool range_is_nonnull (value_range *);
95 extern tree value_range_constant_singleton (value_range *);
96 extern bool symbolic_range_p (value_range *);
97 extern int compare_values (tree, tree);
98 extern int compare_values_warnv (tree, tree, bool *);
99 extern bool vrp_val_is_min (const_tree);
100 extern bool vrp_val_is_max (const_tree);
101 extern void copy_value_range (value_range *, value_range *);
102 extern void set_value_range_to_value (value_range *, tree, bitmap);
103 extern void extract_range_from_binary_expr_1 (value_range *, enum tree_code,
104                                               tree, value_range *,
105                                               value_range *);
106 extern tree vrp_val_min (const_tree);
107 extern tree vrp_val_max (const_tree);
108 extern void set_value_range_to_null (value_range *, tree);
109 extern bool range_int_cst_p (value_range *);
110 extern int operand_less_p (tree, tree);
111 extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *);
112 extern bool find_case_label_index (gswitch *, size_t, tree, size_t *);
113 extern bool zero_nonzero_bits_from_vr (const tree, value_range *,
114                                        wide_int *, wide_int *);
115 extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *);
116 extern bool range_int_cst_singleton_p (value_range *);
117 extern int value_inside_range (tree, tree, tree);
118 extern tree get_single_symbol (tree, bool *, tree *);
119
120
121 struct switch_update {
122   gswitch *stmt;
123   tree vec;
124 };
125
126 extern vec<edge> to_remove_edges;
127 extern vec<switch_update> to_update_switch_stmts;
128
129 #endif /* GCC_TREE_VRP_H */