tree-ssanames.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SSA name expresssons routines
  2. Copyright (C) 2013-2019 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. 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. #ifndef GCC_TREE_SSANAMES_H
  16. #define GCC_TREE_SSANAMES_H
  17. /* Aliasing information for SSA_NAMEs representing pointer variables. */
  18. struct GTY(()) ptr_info_def
  19. {
  20. /* The points-to solution. */
  21. struct pt_solution pt;
  22. /* Alignment and misalignment of the pointer in bytes. Together
  23. align and misalign specify low known bits of the pointer.
  24. ptr & (align - 1) == misalign. */
  25. /* When known, this is the power-of-two byte alignment of the object this
  26. pointer points into. This is usually DECL_ALIGN_UNIT for decls and
  27. MALLOC_ABI_ALIGNMENT for allocated storage. When the alignment is not
  28. known, it is zero. Do not access directly but use functions
  29. get_ptr_info_alignment, set_ptr_info_alignment,
  30. mark_ptr_info_alignment_unknown and similar. */
  31. unsigned int align;
  32. /* When alignment is known, the byte offset this pointer differs from the
  33. above alignment. Access only through the same helper functions as align
  34. above. */
  35. unsigned int misalign;
  36. };
  37. /* Value range information for SSA_NAMEs representing non-pointer variables. */
  38. struct GTY ((variable_size)) range_info_def {
  39. /* Minimum, maximum and nonzero bits. */
  40. TRAILING_WIDE_INT_ACCESSOR (min, ints, 0)
  41. TRAILING_WIDE_INT_ACCESSOR (max, ints, 1)
  42. TRAILING_WIDE_INT_ACCESSOR (nonzero_bits, ints, 2)
  43. trailing_wide_ints <3> ints;
  44. };
  45. #define SSANAMES(fun) (fun)->gimple_df->ssa_names
  46. #define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
  47. #define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names))
  48. #define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)])
  49. #define FOR_EACH_SSA_NAME(I, VAR, FN) \
  50. for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \
  51. if (VAR)
  52. /* Sets the value range to SSA. */
  53. extern void set_range_info (tree, enum value_range_kind, const wide_int_ref &,
  54. const wide_int_ref &);
  55. extern void set_range_info (tree, const value_range_base &);
  56. /* Gets the value range from SSA. */
  57. extern enum value_range_kind get_range_info (const_tree, wide_int *,
  58. wide_int *);
  59. extern enum value_range_kind get_range_info (const_tree, value_range_base &);
  60. extern void set_nonzero_bits (tree, const wide_int_ref &);
  61. extern wide_int get_nonzero_bits (const_tree);
  62. extern bool ssa_name_has_boolean_range (tree);
  63. extern void init_ssanames (struct function *, int);
  64. extern void fini_ssanames (struct function *);
  65. extern void ssanames_print_statistics (void);
  66. extern tree make_ssa_name_fn (struct function *, tree, gimple *,
  67. unsigned int version = 0);
  68. extern void release_ssa_name_fn (struct function *, tree);
  69. extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *,
  70. unsigned int *);
  71. extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *);
  72. extern void set_ptr_info_alignment (struct ptr_info_def *, unsigned int,
  73. unsigned int);
  74. extern void adjust_ptr_info_misalignment (struct ptr_info_def *, poly_uint64);
  75. extern struct ptr_info_def *get_ptr_info (tree);
  76. extern void set_ptr_nonnull (tree);
  77. extern bool get_ptr_nonnull (const_tree);
  78. extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
  79. extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
  80. extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
  81. extern void duplicate_ssa_name_range_info (tree, enum value_range_kind,
  82. struct range_info_def *);
  83. extern void reset_flow_sensitive_info (tree);
  84. extern void reset_flow_sensitive_info_in_bb (basic_block);
  85. extern void release_defs (gimple *);
  86. extern void replace_ssa_name_symbol (tree, tree);
  87. extern void flush_ssaname_freelist (void);
  88. /* Return an SSA_NAME node for variable VAR defined in statement STMT
  89. in function cfun. */
  90. static inline tree
  91. make_ssa_name (tree var, gimple *stmt = NULL)
  92. {
  93. return make_ssa_name_fn (cfun, var, stmt);
  94. }
  95. /* Return an SSA_NAME node using the template SSA name NAME defined in
  96. statement STMT in function cfun. */
  97. static inline tree
  98. copy_ssa_name (tree var, gimple *stmt = NULL)
  99. {
  100. return copy_ssa_name_fn (cfun, var, stmt);
  101. }
  102. /* Creates a duplicate of a SSA name NAME tobe defined by statement STMT
  103. in function cfun. */
  104. static inline tree
  105. duplicate_ssa_name (tree var, gimple *stmt)
  106. {
  107. return duplicate_ssa_name_fn (cfun, var, stmt);
  108. }
  109. /* Release the SSA name NAME used in function cfun. */
  110. static inline void
  111. release_ssa_name (tree name)
  112. {
  113. release_ssa_name_fn (cfun, name);
  114. }
  115. /* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT
  116. in function cfun. Arrange so that it uses NAME in dumps. */
  117. static inline tree
  118. make_temp_ssa_name (tree type, gimple *stmt, const char *name)
  119. {
  120. tree ssa_name;
  121. gcc_checking_assert (TYPE_P (type));
  122. ssa_name = make_ssa_name_fn (cfun, type, stmt);
  123. SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, get_identifier (name));
  124. return ssa_name;
  125. }
  126. #endif /* GCC_TREE_SSANAMES_H */