1*38fd1498Szrj /* Support routines for Value Range Propagation (VRP). 2*38fd1498Szrj Copyright (C) 2016-2018 Free Software Foundation, Inc. 3*38fd1498Szrj 4*38fd1498Szrj This file is part of GCC. 5*38fd1498Szrj 6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify 7*38fd1498Szrj it under the terms of the GNU General Public License as published by 8*38fd1498Szrj the Free Software Foundation; either version 3, or (at your option) 9*38fd1498Szrj any later version. 10*38fd1498Szrj 11*38fd1498Szrj GCC is distributed in the hope that it will be useful, 12*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 13*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*38fd1498Szrj GNU General Public License for more details. 15*38fd1498Szrj 16*38fd1498Szrj You should have received a copy of the GNU General Public License 17*38fd1498Szrj along with GCC; see the file COPYING3. If not see 18*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 19*38fd1498Szrj 20*38fd1498Szrj #ifndef GCC_TREE_VRP_H 21*38fd1498Szrj #define GCC_TREE_VRP_H 22*38fd1498Szrj 23*38fd1498Szrj /* Type of value ranges. See value_range below for a 24*38fd1498Szrj description of these types. */ 25*38fd1498Szrj enum value_range_type { VR_UNDEFINED, VR_RANGE, 26*38fd1498Szrj VR_ANTI_RANGE, VR_VARYING, VR_LAST }; 27*38fd1498Szrj 28*38fd1498Szrj /* Range of values that can be associated with an SSA_NAME after VRP 29*38fd1498Szrj has executed. */ 30*38fd1498Szrj struct GTY((for_user)) value_range 31*38fd1498Szrj { 32*38fd1498Szrj /* Lattice value represented by this range. */ 33*38fd1498Szrj enum value_range_type type; 34*38fd1498Szrj 35*38fd1498Szrj /* Minimum and maximum values represented by this range. These 36*38fd1498Szrj values should be interpreted as follows: 37*38fd1498Szrj 38*38fd1498Szrj - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must 39*38fd1498Szrj be NULL. 40*38fd1498Szrj 41*38fd1498Szrj - If TYPE == VR_RANGE then MIN holds the minimum value and 42*38fd1498Szrj MAX holds the maximum value of the range [MIN, MAX]. 43*38fd1498Szrj 44*38fd1498Szrj - If TYPE == ANTI_RANGE the variable is known to NOT 45*38fd1498Szrj take any values in the range [MIN, MAX]. */ 46*38fd1498Szrj tree min; 47*38fd1498Szrj tree max; 48*38fd1498Szrj 49*38fd1498Szrj /* Set of SSA names whose value ranges are equivalent to this one. 50*38fd1498Szrj This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */ 51*38fd1498Szrj bitmap equiv; 52*38fd1498Szrj }; 53*38fd1498Szrj 54*38fd1498Szrj extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1); 55*38fd1498Szrj extern void vrp_meet (value_range *vr0, const value_range *vr1); 56*38fd1498Szrj extern void dump_value_range (FILE *, const value_range *); 57*38fd1498Szrj extern void extract_range_from_unary_expr (value_range *vr, 58*38fd1498Szrj enum tree_code code, 59*38fd1498Szrj tree type, 60*38fd1498Szrj value_range *vr0_, 61*38fd1498Szrj tree op0_type); 62*38fd1498Szrj 63*38fd1498Szrj extern bool vrp_operand_equal_p (const_tree, const_tree); 64*38fd1498Szrj extern enum value_range_type intersect_range_with_nonzero_bits 65*38fd1498Szrj (enum value_range_type, wide_int *, wide_int *, const wide_int &, signop); 66*38fd1498Szrj 67*38fd1498Szrj struct assert_info 68*38fd1498Szrj { 69*38fd1498Szrj /* Predicate code for the ASSERT_EXPR. Must be COMPARISON_CLASS_P. */ 70*38fd1498Szrj enum tree_code comp_code; 71*38fd1498Szrj 72*38fd1498Szrj /* Name to register the assert for. */ 73*38fd1498Szrj tree name; 74*38fd1498Szrj 75*38fd1498Szrj /* Value being compared against. */ 76*38fd1498Szrj tree val; 77*38fd1498Szrj 78*38fd1498Szrj /* Expression to compare. */ 79*38fd1498Szrj tree expr; 80*38fd1498Szrj }; 81*38fd1498Szrj 82*38fd1498Szrj extern void register_edge_assert_for (tree, edge, enum tree_code, 83*38fd1498Szrj tree, tree, vec<assert_info> &); 84*38fd1498Szrj extern bool stmt_interesting_for_vrp (gimple *); 85*38fd1498Szrj extern void set_value_range_to_varying (value_range *); 86*38fd1498Szrj extern int range_includes_zero_p (tree, tree); 87*38fd1498Szrj extern bool infer_value_range (gimple *, tree, tree_code *, tree *); 88*38fd1498Szrj 89*38fd1498Szrj extern void set_value_range_to_nonnull (value_range *, tree); 90*38fd1498Szrj extern void set_value_range (value_range *, enum value_range_type, tree, 91*38fd1498Szrj tree, bitmap); 92*38fd1498Szrj extern void set_and_canonicalize_value_range (value_range *, 93*38fd1498Szrj enum value_range_type, 94*38fd1498Szrj tree, tree, bitmap); 95*38fd1498Szrj extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap); 96*38fd1498Szrj extern bool range_is_nonnull (value_range *); 97*38fd1498Szrj extern tree value_range_constant_singleton (value_range *); 98*38fd1498Szrj extern bool symbolic_range_p (value_range *); 99*38fd1498Szrj extern int compare_values (tree, tree); 100*38fd1498Szrj extern int compare_values_warnv (tree, tree, bool *); 101*38fd1498Szrj extern bool vrp_val_is_min (const_tree); 102*38fd1498Szrj extern bool vrp_val_is_max (const_tree); 103*38fd1498Szrj extern void copy_value_range (value_range *, value_range *); 104*38fd1498Szrj extern void set_value_range_to_value (value_range *, tree, bitmap); 105*38fd1498Szrj extern void extract_range_from_binary_expr_1 (value_range *, enum tree_code, 106*38fd1498Szrj tree, value_range *, 107*38fd1498Szrj value_range *); 108*38fd1498Szrj extern tree vrp_val_min (const_tree); 109*38fd1498Szrj extern tree vrp_val_max (const_tree); 110*38fd1498Szrj extern void set_value_range_to_null (value_range *, tree); 111*38fd1498Szrj extern bool range_int_cst_p (value_range *); 112*38fd1498Szrj extern int operand_less_p (tree, tree); 113*38fd1498Szrj extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *); 114*38fd1498Szrj extern bool find_case_label_index (gswitch *, size_t, tree, size_t *); 115*38fd1498Szrj extern bool zero_nonzero_bits_from_vr (const tree, value_range *, 116*38fd1498Szrj wide_int *, wide_int *); 117*38fd1498Szrj extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *); 118*38fd1498Szrj extern bool range_int_cst_singleton_p (value_range *); 119*38fd1498Szrj extern int value_inside_range (tree, tree, tree); 120*38fd1498Szrj extern tree get_single_symbol (tree, bool *, tree *); 121*38fd1498Szrj extern void maybe_set_nonzero_bits (edge, tree); 122*38fd1498Szrj 123*38fd1498Szrj 124*38fd1498Szrj struct switch_update { 125*38fd1498Szrj gswitch *stmt; 126*38fd1498Szrj tree vec; 127*38fd1498Szrj }; 128*38fd1498Szrj 129*38fd1498Szrj extern vec<edge> to_remove_edges; 130*38fd1498Szrj extern vec<switch_update> to_update_switch_stmts; 131*38fd1498Szrj 132*38fd1498Szrj #endif /* GCC_TREE_VRP_H */ 133