tree-vrp.h 4.3 KB

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