7 #include "expr_access_type.h"
10 #if defined(__cplusplus)
14 /* Representation of access expression.
16 * For each access expression inside the body of a statement, "ref_id"
17 * is a unique reference identifier.
18 * "index" represents the index expression, while "access"
19 * represents the corresponding access relations.
20 * The output dimension of the index expression may be smaller
21 * than the number of dimensions of the accessed array (recorded
23 * The target space of the access relation, on the other hand,
24 * is equal to the array space.
25 * The entries in "access" may be NULL if they can be derived directly from
26 * "index" and "depth" in construct_access_relation or if they are
27 * irrelevant for the given type of access.
28 * In particular, the entries of "access" may be NULL if there are
29 * no additional constraints on the access relations.
30 * Both "index" and the "access" entries usually map an iteration space
31 * to a (partial) data space.
32 * If the access has arguments, however, then the domain of the
33 * mapping is a wrapped mapping from the iteration space
34 * to a space of dimensionality equal to the number of arguments.
35 * Each dimension in this space corresponds to the value of the
36 * corresponding argument.
38 * The ranges of the index expressions and access relations may
39 * also be wrapped relations, in which case the expression represents
40 * a member access, with the structure represented by the domain
41 * of this wrapped relation and the member represented by the range.
42 * In case of nested member accesses, the domain is itself a wrapped
45 * If the data space is unnamed (and 1D), then it represents
46 * the set of integers. That is, the access represents a value that
47 * is equal to the index.
49 * An access expresssion is marked "read" if it represents a read and
50 * marked "write" if it represents a write. A single access expression
51 * may be marked both read and write.
52 * Alternatively, the expression may be marked "kill", in which case it
53 * is the argument of a kill operation and represents the set of
54 * killed array elements. Such accesses are marked neither read nor write.
55 * Since a kill can never be a read (or a write), the killed access
56 * relation is stored in the same location as the may read access relation.
58 struct pet_expr_access
{
60 isl_multi_pw_aff
*index
;
65 isl_union_map
*access
[pet_expr_access_end
];
67 /* Representation of call expression.
69 * A function call is represented by the name of the called function and
70 * an optional function summary (the value NULL indicating that there is
71 * no function summary).
73 struct pet_expr_call
{
75 pet_function_summary
*summary
;
77 /* Representation of double expression.
79 * A double is represented as both an (approximate) value "val" and
80 * a string representation "s".
82 struct pet_expr_double
{
86 /* d is valid when type == pet_expr_double
87 * i isl valid when type == pet_expr_int
88 * acc is valid when type == pet_expr_access
89 * c is valid when type == pet_expr_call
90 * type is valid when type == pet_expr_cast
91 * op is valid otherwise
93 * "hash" is a copy of the hash value computed by pet_expr_get_hash.
94 * It is zero when it has not been computed yet. The value is reset
95 * whenever the pet_expr is modified (in pet_expr_cow and
96 * introduce_access_relations).
98 * If type_size is not zero, then the expression is of an integer type
99 * and type_size represents the size of the type in bits.
100 * If type_size is greater than zero, then the type is unsigned
101 * and the number of bits is equal to type_size.
102 * If type_size is less than zero, then the type is signed
103 * and the number of bits is equal to -type_size.
104 * type_size may also be zero if the size is (still) unknown.
112 enum pet_expr_type type
;
120 struct pet_expr_access acc
;
122 struct pet_expr_call c
;
124 struct pet_expr_double d
;
129 const char *pet_type_str(enum pet_expr_type type
);
130 enum pet_expr_type
pet_str_type(const char *str
);
132 enum pet_op_type
pet_str_op(const char *str
);
134 __isl_give pet_expr
*pet_expr_alloc(isl_ctx
*ctx
, enum pet_expr_type type
);
135 __isl_give pet_expr
*pet_expr_kill_from_access_and_index(
136 __isl_take isl_map
*access
, __isl_take isl_multi_pw_aff
*index
);
137 __isl_give pet_expr
*pet_expr_new_unary(int type_size
, enum pet_op_type op
,
138 __isl_take pet_expr
*arg
);
139 __isl_give pet_expr
*pet_expr_new_binary(int type_size
, enum pet_op_type op
,
140 __isl_take pet_expr
*lhs
, __isl_take pet_expr
*rhs
);
141 __isl_give pet_expr
*pet_expr_new_ternary(__isl_take pet_expr
*cond
,
142 __isl_take pet_expr
*lhs
, __isl_take pet_expr
*rhs
);
143 __isl_give pet_expr
*pet_expr_new_call(isl_ctx
*ctx
, const char *name
,
145 __isl_give pet_expr
*pet_expr_new_double(isl_ctx
*ctx
, double d
, const char *s
);
146 __isl_give pet_expr
*pet_expr_new_int(__isl_take isl_val
*v
);
148 __isl_give pet_expr
*pet_expr_arg(__isl_take pet_expr
*expr
, int pos
);
150 __isl_give pet_expr
*pet_expr_cow(__isl_take pet_expr
*expr
);
152 __isl_give isl_pw_aff
*pet_expr_extract_affine_condition(
153 __isl_keep pet_expr
*expr
, __isl_keep pet_context
*pc
);
154 __isl_give isl_pw_aff
*pet_expr_extract_comparison(enum pet_op_type op
,
155 __isl_keep pet_expr
*lhs
, __isl_keep pet_expr
*rhs
,
156 __isl_keep pet_context
*pc
);
157 __isl_give pet_expr
*pet_expr_resolve_assume(__isl_take pet_expr
*expr
,
158 __isl_keep pet_context
*pc
);
160 uint32_t pet_expr_get_hash(__isl_keep pet_expr
*expr
);
162 int pet_expr_is_address_of(__isl_keep pet_expr
*expr
);
163 int pet_expr_is_assume(__isl_keep pet_expr
*expr
);
164 int pet_expr_is_boolean(__isl_keep pet_expr
*expr
);
165 int pet_expr_is_comparison(__isl_keep pet_expr
*expr
);
166 int pet_expr_is_min(__isl_keep pet_expr
*expr
);
167 int pet_expr_is_max(__isl_keep pet_expr
*expr
);
168 int pet_expr_is_scalar_access(__isl_keep pet_expr
*expr
);
169 int pet_expr_is_equal(__isl_keep pet_expr
*expr1
, __isl_keep pet_expr
*expr2
);
170 isl_bool
pet_expr_is_same_access(__isl_keep pet_expr
*expr1
,
171 __isl_keep pet_expr
*expr2
);
173 __isl_give isl_pw_aff
*pet_expr_get_affine(__isl_keep pet_expr
*expr
);
174 __isl_give isl_space
*pet_expr_access_get_parameter_space(
175 __isl_take pet_expr
*expr
);
176 __isl_give isl_space
*pet_expr_access_get_augmented_domain_space(
177 __isl_keep pet_expr
*expr
);
178 __isl_give isl_space
*pet_expr_access_get_domain_space(
179 __isl_keep pet_expr
*expr
);
180 __isl_give isl_space
*pet_expr_access_get_data_space(__isl_keep pet_expr
*expr
);
182 isl_bool
pet_expr_access_has_any_access_relation(__isl_keep pet_expr
*expr
);
183 __isl_give isl_union_map
*pet_expr_access_get_dependent_access(
184 __isl_keep pet_expr
*expr
, enum pet_expr_access_type type
);
185 __isl_give isl_map
*pet_expr_access_get_may_access(__isl_keep pet_expr
*expr
);
187 __isl_give pet_expr
*pet_expr_map_top_down(__isl_take pet_expr
*expr
,
188 __isl_give pet_expr
*(*fn
)(__isl_take pet_expr
*expr
, void *user
),
190 __isl_give pet_expr
*pet_expr_map_access(__isl_take pet_expr
*expr
,
191 __isl_give pet_expr
*(*fn
)(__isl_take pet_expr
*expr
, void *user
),
193 __isl_give pet_expr
*pet_expr_map_call(__isl_take pet_expr
*expr
,
194 __isl_give pet_expr
*(*fn
)(__isl_take pet_expr
*expr
, void *user
),
196 __isl_give pet_expr
*pet_expr_map_op(__isl_take pet_expr
*expr
,
197 __isl_give pet_expr
*(*fn
)(__isl_take pet_expr
*expr
, void *user
),
200 __isl_give isl_union_map
*pet_expr_access_get_access(__isl_keep pet_expr
*expr
,
201 enum pet_expr_access_type type
);
202 __isl_give pet_expr
*pet_expr_access_set_access(__isl_take pet_expr
*expr
,
203 enum pet_expr_access_type type
, __isl_take isl_union_map
*access
);
204 __isl_give pet_expr
*pet_expr_access_set_index(__isl_take pet_expr
*expr
,
205 __isl_take isl_multi_pw_aff
*index
);
207 int pet_expr_is_sub_access(__isl_keep pet_expr
*expr1
,
208 __isl_keep pet_expr
*expr2
, int n_arg
);
210 int pet_expr_writes(__isl_keep pet_expr
*expr
, __isl_keep isl_id
*id
);
212 __isl_give pet_expr
*pet_expr_access_move_dims(__isl_take pet_expr
*expr
,
213 enum isl_dim_type dst_type
, unsigned dst_pos
,
214 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
);
215 __isl_give pet_expr
*pet_expr_access_pullback_multi_aff(
216 __isl_take pet_expr
*expr
, __isl_take isl_multi_aff
*ma
);
217 __isl_give pet_expr
*pet_expr_access_pullback_multi_pw_aff(
218 __isl_take pet_expr
*expr
, __isl_take isl_multi_pw_aff
*mpa
);
219 __isl_give pet_expr
*pet_expr_access_align_params(__isl_take pet_expr
*expr
);
220 __isl_give pet_expr
*pet_expr_restrict(__isl_take pet_expr
*expr
,
221 __isl_take isl_set
*cond
);
222 __isl_give pet_expr
*pet_expr_access_update_domain(__isl_take pet_expr
*expr
,
223 __isl_keep isl_multi_pw_aff
*update
);
224 __isl_give pet_expr
*pet_expr_update_domain(__isl_take pet_expr
*expr
,
225 __isl_take isl_multi_pw_aff
*update
);
226 __isl_give pet_expr
*pet_expr_align_params(__isl_take pet_expr
*expr
,
227 __isl_take isl_space
*space
);
228 __isl_give pet_expr
*pet_expr_filter(__isl_take pet_expr
*expr
,
229 __isl_take isl_multi_pw_aff
*test
, int satisfied
);
230 __isl_give pet_expr
*pet_expr_add_ref_ids(__isl_take pet_expr
*expr
,
232 __isl_give pet_expr
*pet_expr_anonymize(__isl_take pet_expr
*expr
);
233 __isl_give pet_expr
*pet_expr_gist(__isl_take pet_expr
*expr
,
234 __isl_keep isl_set
*context
, __isl_keep isl_union_map
*value_bounds
);
236 __isl_give isl_union_map
*pet_expr_tag_access(__isl_keep pet_expr
*expr
,
237 __isl_take isl_union_map
*access
);
239 __isl_give pet_expr
*pet_expr_access_subscript(__isl_take pet_expr
*base
,
240 __isl_take pet_expr
*index
);
241 __isl_give pet_expr
*pet_expr_access_member(__isl_take pet_expr
*base
,
242 __isl_take isl_id
*member
);
244 int pet_expr_call_has_summary(__isl_keep pet_expr
*expr
);
245 __isl_give pet_function_summary
*pet_expr_call_get_summary(
246 __isl_keep pet_expr
*expr
);
247 __isl_give pet_expr
*pet_expr_call_set_summary(__isl_take pet_expr
*expr
,
248 __isl_take pet_function_summary
*summary
);
250 int pet_expr_get_type_size(__isl_keep pet_expr
*expr
);
251 __isl_give pet_expr
*pet_expr_set_type_size(__isl_take pet_expr
*expr
,
253 __isl_give pet_expr
*pet_expr_access_set_depth(__isl_take pet_expr
*expr
,
256 __isl_give pet_expr
*pet_expr_insert_domain(__isl_take pet_expr
*expr
,
257 __isl_take isl_space
*space
);
259 __isl_give pet_expr
*pet_expr_access_patch(__isl_take pet_expr
*expr
,
260 __isl_take isl_multi_pw_aff
*prefix
, int add
);
262 __isl_give isl_printer
*pet_expr_print(__isl_keep pet_expr
*expr
,
263 __isl_take isl_printer
*p
);
264 void pet_expr_dump_with_indent(__isl_keep pet_expr
*expr
, int indent
);
266 #if defined(__cplusplus)