Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-chrec.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Chains of recurrences. | 1 /* Chains of recurrences. |
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 2 Copyright (C) 2003-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 Contributed by Sebastian Pop <pop@cri.ensmp.fr> | 3 Contributed by Sebastian Pop <pop@cri.ensmp.fr> |
5 | 4 |
6 This file is part of GCC. | 5 This file is part of GCC. |
7 | 6 |
8 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
51 else | 50 else |
52 return false; | 51 return false; |
53 } | 52 } |
54 | 53 |
55 | 54 |
55 enum ev_direction {EV_DIR_GROWS, EV_DIR_DECREASES, EV_DIR_UNKNOWN}; | |
56 enum ev_direction scev_direction (const_tree); | |
56 | 57 |
57 /* Chrec folding functions. */ | 58 /* Chrec folding functions. */ |
58 extern tree chrec_fold_plus (tree, tree, tree); | 59 extern tree chrec_fold_plus (tree, tree, tree); |
59 extern tree chrec_fold_minus (tree, tree, tree); | 60 extern tree chrec_fold_minus (tree, tree, tree); |
60 extern tree chrec_fold_multiply (tree, tree, tree); | 61 extern tree chrec_fold_multiply (tree, tree, tree); |
61 extern tree chrec_convert (tree, tree, gimple); | 62 extern tree chrec_convert (tree, tree, gimple *, bool = true, tree = NULL); |
62 extern tree chrec_convert_rhs (tree, tree, gimple); | 63 extern tree chrec_convert_rhs (tree, tree, gimple *); |
63 extern tree chrec_convert_aggressive (tree, tree); | 64 extern tree chrec_convert_aggressive (tree, tree, bool *); |
64 | 65 |
65 /* Operations. */ | 66 /* Operations. */ |
66 extern tree chrec_apply (unsigned, tree, tree); | 67 extern tree chrec_apply (unsigned, tree, tree); |
67 extern tree chrec_apply_map (tree, VEC (tree, heap) *); | 68 extern tree chrec_apply_map (tree, vec<tree> ); |
68 extern tree chrec_replace_initial_condition (tree, tree); | 69 extern tree chrec_replace_initial_condition (tree, tree); |
69 extern tree initial_condition (tree); | 70 extern tree initial_condition (tree); |
70 extern tree initial_condition_in_loop_num (tree, unsigned); | 71 extern tree initial_condition_in_loop_num (tree, unsigned); |
71 extern tree evolution_part_in_loop_num (tree, unsigned); | 72 extern tree evolution_part_in_loop_num (tree, unsigned); |
72 extern tree hide_evolution_in_other_loops_than_loop (tree, unsigned); | 73 extern tree hide_evolution_in_other_loops_than_loop (tree, unsigned); |
73 extern tree reset_evolution_in_loop (unsigned, tree, tree); | 74 extern tree reset_evolution_in_loop (unsigned, tree, tree); |
74 extern tree chrec_merge (tree, tree); | 75 extern tree chrec_merge (tree, tree); |
75 extern void for_each_scev_op (tree *, bool (*) (tree *, void *), void *); | 76 extern void for_each_scev_op (tree *, bool (*) (tree *, void *), void *); |
77 extern bool convert_affine_scev (struct loop *, tree, tree *, tree *, gimple *, | |
78 bool, tree = NULL); | |
76 | 79 |
77 /* Observers. */ | 80 /* Observers. */ |
78 extern bool eq_evolutions_p (const_tree, const_tree); | 81 extern bool eq_evolutions_p (const_tree, const_tree); |
79 extern bool is_multivariate_chrec (const_tree); | 82 extern bool is_multivariate_chrec (const_tree); |
80 extern bool chrec_is_positive (tree, bool *); | |
81 extern bool chrec_contains_symbols (const_tree); | 83 extern bool chrec_contains_symbols (const_tree); |
82 extern bool chrec_contains_symbols_defined_in_loop (const_tree, unsigned); | 84 extern bool chrec_contains_symbols_defined_in_loop (const_tree, unsigned); |
83 extern bool chrec_contains_undetermined (const_tree); | 85 extern bool chrec_contains_undetermined (const_tree); |
84 extern bool tree_contains_chrecs (const_tree, int *); | 86 extern bool tree_contains_chrecs (const_tree, int *); |
85 extern bool evolution_function_is_affine_multivariate_p (const_tree, int); | 87 extern bool evolution_function_is_affine_multivariate_p (const_tree, int); |
116 || chrec_contains_symbols_defined_in_loop (chrec, loop_num)) | 118 || chrec_contains_symbols_defined_in_loop (chrec, loop_num)) |
117 return false; | 119 return false; |
118 | 120 |
119 STRIP_NOPS (chrec); | 121 STRIP_NOPS (chrec); |
120 scev = hide_evolution_in_other_loops_than_loop (chrec, loop_num); | 122 scev = hide_evolution_in_other_loops_than_loop (chrec, loop_num); |
121 *res = !tree_is_chrec (scev); | 123 *res = !tree_contains_chrecs (scev, NULL); |
122 return true; | 124 return true; |
123 } | 125 } |
124 | 126 |
125 /* Build a polynomial chain of recurrence. */ | 127 /* Build a polynomial chain of recurrence. */ |
126 | 128 |
137 | 139 |
138 if (!no_evolution_in_loop_p (left, loop_num, &val) | 140 if (!no_evolution_in_loop_p (left, loop_num, &val) |
139 || !val) | 141 || !val) |
140 return chrec_dont_know; | 142 return chrec_dont_know; |
141 | 143 |
142 /* Pointer types should occur only on the left hand side, i.e. in | 144 /* Types of left and right sides of a chrec should be compatible, but |
143 the base of the chrec, and not in the step. */ | 145 pointer CHRECs are special in that the evolution is of ptroff type. */ |
144 gcc_assert (!POINTER_TYPE_P (TREE_TYPE (right))); | |
145 | |
146 /* Types of left and right sides of a chrec should be compatible. */ | |
147 if (POINTER_TYPE_P (TREE_TYPE (left))) | 146 if (POINTER_TYPE_P (TREE_TYPE (left))) |
148 gcc_assert (sizetype == TREE_TYPE (right)); | 147 gcc_checking_assert (ptrofftype_p (TREE_TYPE (right))); |
149 else | 148 else |
150 gcc_assert (TREE_TYPE (left) == TREE_TYPE (right)); | 149 { |
150 /* Pointer types should occur only on the left hand side, i.e. in | |
151 the base of the chrec, and not in the step. */ | |
152 gcc_checking_assert (!POINTER_TYPE_P (TREE_TYPE (right)) | |
153 && types_compatible_p (TREE_TYPE (left), | |
154 TREE_TYPE (right))); | |
155 } | |
151 | 156 |
152 if (chrec_zerop (right)) | 157 if (chrec_zerop (right)) |
153 return left; | 158 return left; |
154 | 159 |
155 return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left), | 160 tree chrec = build2 (POLYNOMIAL_CHREC, TREE_TYPE (left), left, right); |
156 build_int_cst (NULL_TREE, loop_num), left, right); | 161 CHREC_VARIABLE (chrec) = loop_num; |
162 return chrec; | |
157 } | 163 } |
158 | 164 |
159 /* Determines whether the expression CHREC is a constant. */ | 165 /* Determines whether the expression CHREC is a constant. */ |
160 | 166 |
161 static inline bool | 167 static inline bool |
162 evolution_function_is_constant_p (const_tree chrec) | 168 evolution_function_is_constant_p (const_tree chrec) |
163 { | 169 { |
164 if (chrec == NULL_TREE) | 170 if (chrec == NULL_TREE) |
165 return false; | 171 return false; |
166 | 172 |
167 switch (TREE_CODE (chrec)) | 173 if (CONSTANT_CLASS_P (chrec)) |
168 { | 174 return true; |
169 case INTEGER_CST: | 175 return is_gimple_min_invariant (chrec); |
170 case REAL_CST: | |
171 return true; | |
172 | |
173 default: | |
174 return false; | |
175 } | |
176 } | 176 } |
177 | 177 |
178 /* Determine whether CHREC is an affine evolution function in LOOPNUM. */ | 178 /* Determine whether CHREC is an affine evolution function in LOOPNUM. */ |
179 | 179 |
180 static inline bool | 180 static inline bool |
203 evolution_function_is_affine_p (const_tree chrec) | 203 evolution_function_is_affine_p (const_tree chrec) |
204 { | 204 { |
205 return chrec | 205 return chrec |
206 && TREE_CODE (chrec) == POLYNOMIAL_CHREC | 206 && TREE_CODE (chrec) == POLYNOMIAL_CHREC |
207 && evolution_function_is_invariant_p (CHREC_RIGHT (chrec), | 207 && evolution_function_is_invariant_p (CHREC_RIGHT (chrec), |
208 CHREC_VARIABLE (chrec)); | 208 CHREC_VARIABLE (chrec)) |
209 && (TREE_CODE (CHREC_RIGHT (chrec)) != POLYNOMIAL_CHREC | |
210 || evolution_function_is_affine_p (CHREC_RIGHT (chrec))); | |
209 } | 211 } |
210 | 212 |
211 /* Determines whether EXPR does not contains chrec expressions. */ | 213 /* Determines whether EXPR does not contains chrec expressions. */ |
212 | 214 |
213 static inline bool | 215 static inline bool |