您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

130 行
3.8KB

  1. /* Operations with affine combinations of trees.
  2. Copyright (C) 2005-2020 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 3, or (at your option) any
  7. later version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. 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. /* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements
  16. to make things simpler; this is sufficient in most cases. */
  17. #ifndef GCC_TREE_AFFINE_H
  18. #define GCC_TREE_AFFINE_H
  19. #define MAX_AFF_ELTS 8
  20. /* Element of an affine combination. */
  21. class aff_comb_elt
  22. {
  23. public:
  24. /* The value of the element. */
  25. tree val;
  26. /* Its coefficient in the combination. */
  27. widest_int coef;
  28. };
  29. class aff_tree
  30. {
  31. public:
  32. /* Type of the result of the combination. */
  33. tree type;
  34. /* Constant offset. */
  35. poly_widest_int offset;
  36. /* Number of elements of the combination. */
  37. unsigned n;
  38. /* Elements and their coefficients. Type of elements may be different from
  39. TYPE, but their sizes must be the same (STRIP_NOPS is applied to the
  40. elements).
  41. The coefficients are always sign extended from the precision of TYPE
  42. (regardless of signedness of TYPE). */
  43. class aff_comb_elt elts[MAX_AFF_ELTS];
  44. /* Remainder of the expression. Usually NULL, used only if there are more
  45. than MAX_AFF_ELTS elements. Type of REST will be either sizetype for
  46. TYPE of POINTER_TYPEs or TYPE. */
  47. tree rest;
  48. };
  49. class name_expansion;
  50. void aff_combination_const (aff_tree *, tree, const poly_widest_int &);
  51. void aff_combination_elt (aff_tree *, tree, tree);
  52. void aff_combination_scale (aff_tree *, const widest_int &);
  53. void aff_combination_mult (aff_tree *, aff_tree *, aff_tree *);
  54. void aff_combination_add (aff_tree *, aff_tree *);
  55. void aff_combination_add_elt (aff_tree *, tree, const widest_int &);
  56. void aff_combination_remove_elt (aff_tree *, unsigned);
  57. void aff_combination_convert (aff_tree *, tree);
  58. void tree_to_aff_combination (tree, tree, aff_tree *);
  59. tree aff_combination_to_tree (aff_tree *);
  60. void unshare_aff_combination (aff_tree *);
  61. bool aff_combination_constant_multiple_p (aff_tree *, aff_tree *,
  62. poly_widest_int *);
  63. void aff_combination_expand (aff_tree *, hash_map<tree, name_expansion *> **);
  64. void tree_to_aff_combination_expand (tree, tree, aff_tree *,
  65. hash_map<tree, name_expansion *> **);
  66. tree get_inner_reference_aff (tree, aff_tree *, poly_widest_int *);
  67. void free_affine_expand_cache (hash_map<tree, name_expansion *> **);
  68. bool aff_comb_cannot_overlap_p (aff_tree *, const poly_widest_int &,
  69. const poly_widest_int &);
  70. /* Debugging functions. */
  71. void debug_aff (aff_tree *);
  72. /* Return AFF's type. */
  73. inline tree
  74. aff_combination_type (aff_tree *aff)
  75. {
  76. return aff->type;
  77. }
  78. /* Return true if AFF is actually ZERO. */
  79. inline bool
  80. aff_combination_zero_p (aff_tree *aff)
  81. {
  82. if (!aff)
  83. return true;
  84. if (aff->n == 0 && known_eq (aff->offset, 0))
  85. return true;
  86. return false;
  87. }
  88. /* Return true if AFF is actually const. */
  89. inline bool
  90. aff_combination_const_p (aff_tree *aff)
  91. {
  92. return (aff == NULL || aff->n == 0);
  93. }
  94. /* Return true iff AFF contains one (negated) singleton variable. Users need
  95. to make sure AFF points to a valid combination. */
  96. inline bool
  97. aff_combination_singleton_var_p (aff_tree *aff)
  98. {
  99. return (aff->n == 1
  100. && known_eq (aff->offset, 0)
  101. && (aff->elts[0].coef == 1 || aff->elts[0].coef == -1));
  102. }
  103. #endif /* GCC_TREE_AFFINE_H */