fold-const.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* Fold a constant sub-tree into a single node for C-compiler
  2. Copyright (C) 1987-2015 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_FOLD_CONST_H
  16. #define GCC_FOLD_CONST_H
  17. /* Non-zero if we are folding constants inside an initializer; zero
  18. otherwise. */
  19. extern int folding_initializer;
  20. /* Convert between trees and native memory representation. */
  21. extern int native_encode_expr (const_tree, unsigned char *, int, int off = -1);
  22. extern tree native_interpret_expr (tree, const unsigned char *, int);
  23. /* Fold constants as much as possible in an expression.
  24. Returns the simplified expression.
  25. Acts only on the top level of the expression;
  26. if the argument itself cannot be simplified, its
  27. subexpressions are not changed. */
  28. extern tree fold (tree);
  29. #define fold_unary(CODE,T1,T2)\
  30. fold_unary_loc (UNKNOWN_LOCATION, CODE, T1, T2)
  31. extern tree fold_unary_loc (location_t, enum tree_code, tree, tree);
  32. #define fold_unary_ignore_overflow(CODE,T1,T2)\
  33. fold_unary_ignore_overflow_loc (UNKNOWN_LOCATION, CODE, T1, T2)
  34. extern tree fold_unary_ignore_overflow_loc (location_t, enum tree_code, tree, tree);
  35. #define fold_binary(CODE,T1,T2,T3)\
  36. fold_binary_loc (UNKNOWN_LOCATION, CODE, T1, T2, T3)
  37. extern tree fold_binary_loc (location_t, enum tree_code, tree, tree, tree);
  38. #define fold_ternary(CODE,T1,T2,T3,T4)\
  39. fold_ternary_loc (UNKNOWN_LOCATION, CODE, T1, T2, T3, T4)
  40. extern tree fold_ternary_loc (location_t, enum tree_code, tree, tree, tree, tree);
  41. #define fold_build1(c,t1,t2)\
  42. fold_build1_stat_loc (UNKNOWN_LOCATION, c, t1, t2 MEM_STAT_INFO)
  43. #define fold_build1_loc(l,c,t1,t2)\
  44. fold_build1_stat_loc (l, c, t1, t2 MEM_STAT_INFO)
  45. extern tree fold_build1_stat_loc (location_t, enum tree_code, tree,
  46. tree MEM_STAT_DECL);
  47. #define fold_build2(c,t1,t2,t3)\
  48. fold_build2_stat_loc (UNKNOWN_LOCATION, c, t1, t2, t3 MEM_STAT_INFO)
  49. #define fold_build2_loc(l,c,t1,t2,t3)\
  50. fold_build2_stat_loc (l, c, t1, t2, t3 MEM_STAT_INFO)
  51. extern tree fold_build2_stat_loc (location_t, enum tree_code, tree, tree,
  52. tree MEM_STAT_DECL);
  53. #define fold_build3(c,t1,t2,t3,t4)\
  54. fold_build3_stat_loc (UNKNOWN_LOCATION, c, t1, t2, t3, t4 MEM_STAT_INFO)
  55. #define fold_build3_loc(l,c,t1,t2,t3,t4)\
  56. fold_build3_stat_loc (l, c, t1, t2, t3, t4 MEM_STAT_INFO)
  57. extern tree fold_build3_stat_loc (location_t, enum tree_code, tree, tree, tree,
  58. tree MEM_STAT_DECL);
  59. extern tree fold_build1_initializer_loc (location_t, enum tree_code, tree, tree);
  60. extern tree fold_build2_initializer_loc (location_t, enum tree_code, tree, tree, tree);
  61. #define fold_build_call_array(T1,T2,N,T4)\
  62. fold_build_call_array_loc (UNKNOWN_LOCATION, T1, T2, N, T4)
  63. extern tree fold_build_call_array_loc (location_t, tree, tree, int, tree *);
  64. #define fold_build_call_array_initializer(T1,T2,N,T4)\
  65. fold_build_call_array_initializer_loc (UNKNOWN_LOCATION, T1, T2, N, T4)
  66. extern tree fold_build_call_array_initializer_loc (location_t, tree, tree, int, tree *);
  67. extern bool fold_convertible_p (const_tree, const_tree);
  68. #define fold_convert(T1,T2)\
  69. fold_convert_loc (UNKNOWN_LOCATION, T1, T2)
  70. extern tree fold_convert_loc (location_t, tree, tree);
  71. extern tree fold_single_bit_test (location_t, enum tree_code, tree, tree, tree);
  72. extern tree fold_ignored_result (tree);
  73. extern tree fold_abs_const (tree, tree);
  74. extern tree fold_indirect_ref_1 (location_t, tree, tree);
  75. extern void fold_defer_overflow_warnings (void);
  76. extern void fold_undefer_overflow_warnings (bool, const_gimple, int);
  77. extern void fold_undefer_and_ignore_overflow_warnings (void);
  78. extern bool fold_deferring_overflow_warnings_p (void);
  79. extern int operand_equal_p (const_tree, const_tree, unsigned int);
  80. extern int multiple_of_p (tree, const_tree, const_tree);
  81. #define omit_one_operand(T1,T2,T3)\
  82. omit_one_operand_loc (UNKNOWN_LOCATION, T1, T2, T3)
  83. extern tree omit_one_operand_loc (location_t, tree, tree, tree);
  84. #define omit_two_operands(T1,T2,T3,T4)\
  85. omit_two_operands_loc (UNKNOWN_LOCATION, T1, T2, T3, T4)
  86. extern tree omit_two_operands_loc (location_t, tree, tree, tree, tree);
  87. #define invert_truthvalue(T)\
  88. invert_truthvalue_loc (UNKNOWN_LOCATION, T)
  89. extern tree invert_truthvalue_loc (location_t, tree);
  90. extern tree fold_unary_to_constant (enum tree_code, tree, tree);
  91. extern tree fold_binary_to_constant (enum tree_code, tree, tree, tree);
  92. extern tree fold_read_from_constant_string (tree);
  93. extern tree int_const_binop (enum tree_code, const_tree, const_tree);
  94. #define build_fold_addr_expr(T)\
  95. build_fold_addr_expr_loc (UNKNOWN_LOCATION, (T))
  96. extern tree build_fold_addr_expr_loc (location_t, tree);
  97. #define build_fold_addr_expr_with_type(T,TYPE)\
  98. build_fold_addr_expr_with_type_loc (UNKNOWN_LOCATION, (T), TYPE)
  99. extern tree build_fold_addr_expr_with_type_loc (location_t, tree, tree);
  100. extern tree fold_build_cleanup_point_expr (tree type, tree expr);
  101. extern tree fold_strip_sign_ops (tree);
  102. #define build_fold_indirect_ref(T)\
  103. build_fold_indirect_ref_loc (UNKNOWN_LOCATION, T)
  104. extern tree build_fold_indirect_ref_loc (location_t, tree);
  105. #define fold_indirect_ref(T)\
  106. fold_indirect_ref_loc (UNKNOWN_LOCATION, T)
  107. extern tree fold_indirect_ref_loc (location_t, tree);
  108. extern tree build_simple_mem_ref_loc (location_t, tree);
  109. #define build_simple_mem_ref(T)\
  110. build_simple_mem_ref_loc (UNKNOWN_LOCATION, T)
  111. extern offset_int mem_ref_offset (const_tree);
  112. extern tree build_invariant_address (tree, tree, HOST_WIDE_INT);
  113. extern tree constant_boolean_node (bool, tree);
  114. extern tree div_if_zero_remainder (const_tree, const_tree);
  115. extern bool tree_swap_operands_p (const_tree, const_tree, bool);
  116. extern enum tree_code swap_tree_comparison (enum tree_code);
  117. extern bool ptr_difference_const (tree, tree, HOST_WIDE_INT *);
  118. extern enum tree_code invert_tree_comparison (enum tree_code, bool);
  119. extern bool tree_unary_nonzero_warnv_p (enum tree_code, tree, tree, bool *);
  120. extern bool tree_binary_nonzero_warnv_p (enum tree_code, tree, tree, tree op1,
  121. bool *);
  122. extern bool tree_single_nonzero_warnv_p (tree, bool *);
  123. extern bool tree_unary_nonnegative_warnv_p (enum tree_code, tree, tree, bool *);
  124. extern bool tree_binary_nonnegative_warnv_p (enum tree_code, tree, tree, tree,
  125. bool *);
  126. extern bool tree_single_nonnegative_warnv_p (tree t, bool *strict_overflow_p);
  127. extern bool tree_call_nonnegative_warnv_p (tree, tree, tree, tree, bool *);
  128. extern bool fold_real_zero_addition_p (const_tree, const_tree, int);
  129. extern tree combine_comparisons (location_t, enum tree_code, enum tree_code,
  130. enum tree_code, tree, tree, tree);
  131. extern void debug_fold_checksum (const_tree);
  132. extern bool may_negate_without_overflow_p (const_tree);
  133. #define round_up(T,N) round_up_loc (UNKNOWN_LOCATION, T, N)
  134. extern tree round_up_loc (location_t, tree, unsigned int);
  135. #define round_down(T,N) round_down_loc (UNKNOWN_LOCATION, T, N)
  136. extern tree round_down_loc (location_t, tree, int);
  137. extern tree size_int_kind (HOST_WIDE_INT, enum size_type_kind);
  138. #define size_binop(CODE,T1,T2)\
  139. size_binop_loc (UNKNOWN_LOCATION, CODE, T1, T2)
  140. extern tree size_binop_loc (location_t, enum tree_code, tree, tree);
  141. #define size_diffop(T1,T2)\
  142. size_diffop_loc (UNKNOWN_LOCATION, T1, T2)
  143. extern tree size_diffop_loc (location_t, tree, tree);
  144. /* Return an expr equal to X but certainly not valid as an lvalue. */
  145. #define non_lvalue(T) non_lvalue_loc (UNKNOWN_LOCATION, T)
  146. extern tree non_lvalue_loc (location_t, tree);
  147. extern bool tree_expr_nonnegative_p (tree);
  148. extern bool tree_expr_nonnegative_warnv_p (tree, bool *);
  149. extern tree make_range (tree, int *, tree *, tree *, bool *);
  150. extern tree make_range_step (location_t, enum tree_code, tree, tree, tree,
  151. tree *, tree *, int *, bool *);
  152. extern tree build_range_check (location_t, tree, tree, int, tree, tree);
  153. extern bool merge_ranges (int *, tree *, tree *, int, tree, tree, int,
  154. tree, tree);
  155. extern tree sign_bit_p (tree, const_tree);
  156. extern tree exact_inverse (tree, tree);
  157. extern tree const_unop (enum tree_code, tree, tree);
  158. extern tree const_binop (enum tree_code, tree, tree, tree);
  159. /* Return OFF converted to a pointer offset type suitable as offset for
  160. POINTER_PLUS_EXPR. Use location LOC for this conversion. */
  161. extern tree convert_to_ptrofftype_loc (location_t loc, tree off);
  162. #define convert_to_ptrofftype(t) convert_to_ptrofftype_loc (UNKNOWN_LOCATION, t)
  163. /* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */
  164. extern tree fold_build_pointer_plus_loc (location_t loc, tree ptr, tree off);
  165. #define fold_build_pointer_plus(p,o) \
  166. fold_build_pointer_plus_loc (UNKNOWN_LOCATION, p, o)
  167. /* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */
  168. extern tree fold_build_pointer_plus_hwi_loc (location_t loc, tree ptr, HOST_WIDE_INT off);
  169. #define fold_build_pointer_plus_hwi(p,o) \
  170. fold_build_pointer_plus_hwi_loc (UNKNOWN_LOCATION, p, o)
  171. #endif // GCC_FOLD_CONST_H