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 * If type_size is not zero, then the expression is of an integer type
94 * and type_size represents the size of the type in bits.
95 * If type_size is greater than zero, then the type is unsigned
96 * and the number of bits is equal to type_size.
97 * If type_size is less than zero, then the type is signed
98 * and the number of bits is equal to -type_size.
99 * type_size may also be zero if the size is (still) unknown.
105 enum pet_expr_type type
;
113 struct pet_expr_access acc
;
115 struct pet_expr_call c
;
117 struct pet_expr_double d
;
122 const char *pet_type_str(enum pet_expr_type type
);
123 enum pet_expr_type
pet_str_type(const char *str
);
125 enum pet_op_type
pet_str_op(const char *str
);
127 __isl_give pet_expr
*pet_expr_alloc(isl_ctx
*ctx
, enum pet_expr_type type
);
128 __isl_give pet_expr
*pet_expr_kill_from_access_and_index(
129 __isl_take isl_map
*access
, __isl_take isl_multi_pw_aff
*index
);
130 __isl_give pet_expr
*pet_expr_new_unary(int type_size
, enum pet_op_type op
,
131 __isl_take pet_expr
*arg
);
132 __isl_give pet_expr
*pet_expr_new_binary(int type_size
, enum pet_op_type op
,
133 __isl_take pet_expr
*lhs
, __isl_take pet_expr
*rhs
);
134 __isl_give pet_expr
*pet_expr_new_ternary(__isl_take pet_expr
*cond
,
135 __isl_take pet_expr
*lhs
, __isl_take pet_expr
*rhs
);
136 __isl_give pet_expr
*pet_expr_new_call(isl_ctx
*ctx
, const char *name
,
138 __isl_give pet_expr
*pet_expr_new_double(isl_ctx
*ctx
, double d
, const char *s
);
139 __isl_give pet_expr
*pet_expr_new_int(__isl_take isl_val
*v
);
141 __isl_give pet_expr
*pet_expr_arg(__isl_take pet_expr
*expr
, int pos
);
143 __isl_give pet_expr
*pet_expr_cow(__isl_take pet_expr
*expr
);
145 __isl_give isl_pw_aff
*pet_expr_extract_affine_condition(
146 __isl_keep pet_expr
*expr
, __isl_keep pet_context
*pc
);
147 __isl_give isl_pw_aff
*pet_expr_extract_comparison(enum pet_op_type op
,
148 __isl_keep pet_expr
*lhs
, __isl_keep pet_expr
*rhs
,
149 __isl_keep pet_context
*pc
);
150 __isl_give pet_expr
*pet_expr_resolve_assume(__isl_take pet_expr
*expr
,
151 __isl_keep pet_context
*pc
);
153 int pet_expr_is_address_of(__isl_keep pet_expr
*expr
);
154 int pet_expr_is_assume(__isl_keep pet_expr
*expr
);
155 int pet_expr_is_boolean(__isl_keep pet_expr
*expr
);
156 int pet_expr_is_comparison(__isl_keep pet_expr
*expr
);
157 int pet_expr_is_min(__isl_keep pet_expr
*expr
);
158 int pet_expr_is_max(__isl_keep pet_expr
*expr
);
159 int pet_expr_is_scalar_access(__isl_keep pet_expr
*expr
);
160 int pet_expr_is_equal(__isl_keep pet_expr
*expr1
, __isl_keep pet_expr
*expr2
);
162 __isl_give isl_space
*pet_expr_access_get_parameter_space(
163 __isl_take pet_expr
*expr
);
164 __isl_give isl_space
*pet_expr_access_get_augmented_domain_space(
165 __isl_keep pet_expr
*expr
);
166 __isl_give isl_space
*pet_expr_access_get_domain_space(
167 __isl_keep pet_expr
*expr
);
168 __isl_give isl_space
*pet_expr_access_get_data_space(__isl_keep pet_expr
*expr
);
170 __isl_give isl_union_map
*pet_expr_access_get_dependent_access(
171 __isl_keep pet_expr
*expr
, enum pet_expr_access_type type
);
172 __isl_give isl_map
*pet_expr_access_get_may_access(__isl_keep pet_expr
*expr
);
174 __isl_give pet_expr
*pet_expr_map_access(__isl_take pet_expr
*expr
,
175 __isl_give pet_expr
*(*fn
)(__isl_take pet_expr
*expr
, void *user
),
177 __isl_give pet_expr
*pet_expr_map_call(__isl_take pet_expr
*expr
,
178 __isl_give pet_expr
*(*fn
)(__isl_take pet_expr
*expr
, void *user
),
181 __isl_give isl_union_map
*pet_expr_access_get_access(__isl_keep pet_expr
*expr
,
182 enum pet_expr_access_type type
);
183 __isl_give pet_expr
*pet_expr_access_set_access(__isl_take pet_expr
*expr
,
184 enum pet_expr_access_type type
, __isl_take isl_union_map
*access
);
185 __isl_give pet_expr
*pet_expr_access_set_index(__isl_take pet_expr
*expr
,
186 __isl_take isl_multi_pw_aff
*index
);
188 int pet_expr_is_sub_access(__isl_keep pet_expr
*expr1
,
189 __isl_keep pet_expr
*expr2
, int n_arg
);
191 int pet_expr_writes(__isl_keep pet_expr
*expr
, __isl_keep isl_id
*id
);
193 __isl_give pet_expr
*pet_expr_access_move_dims(__isl_take pet_expr
*expr
,
194 enum isl_dim_type dst_type
, unsigned dst_pos
,
195 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
);
196 __isl_give pet_expr
*pet_expr_access_pullback_multi_aff(
197 __isl_take pet_expr
*expr
, __isl_take isl_multi_aff
*ma
);
198 __isl_give pet_expr
*pet_expr_access_pullback_multi_pw_aff(
199 __isl_take pet_expr
*expr
, __isl_take isl_multi_pw_aff
*mpa
);
200 __isl_give pet_expr
*pet_expr_access_align_params(__isl_take pet_expr
*expr
);
201 __isl_give pet_expr
*pet_expr_restrict(__isl_take pet_expr
*expr
,
202 __isl_take isl_set
*cond
);
203 __isl_give pet_expr
*pet_expr_access_update_domain(__isl_take pet_expr
*expr
,
204 __isl_keep isl_multi_pw_aff
*update
);
205 __isl_give pet_expr
*pet_expr_update_domain(__isl_take pet_expr
*expr
,
206 __isl_take isl_multi_pw_aff
*update
);
207 __isl_give pet_expr
*pet_expr_align_params(__isl_take pet_expr
*expr
,
208 __isl_take isl_space
*space
);
209 __isl_give pet_expr
*pet_expr_filter(__isl_take pet_expr
*expr
,
210 __isl_take isl_multi_pw_aff
*test
, int satisfied
);
211 __isl_give pet_expr
*pet_expr_add_ref_ids(__isl_take pet_expr
*expr
,
213 __isl_give pet_expr
*pet_expr_anonymize(__isl_take pet_expr
*expr
);
214 __isl_give pet_expr
*pet_expr_gist(__isl_take pet_expr
*expr
,
215 __isl_keep isl_set
*context
, __isl_keep isl_union_map
*value_bounds
);
217 __isl_give isl_union_map
*pet_expr_tag_access(__isl_keep pet_expr
*expr
,
218 __isl_take isl_union_map
*access
);
220 __isl_give pet_expr
*pet_expr_access_subscript(__isl_take pet_expr
*base
,
221 __isl_take pet_expr
*index
);
222 __isl_give pet_expr
*pet_expr_access_member(__isl_take pet_expr
*base
,
223 __isl_take isl_id
*member
);
225 int pet_expr_call_has_summary(__isl_keep pet_expr
*expr
);
226 __isl_give pet_function_summary
*pet_expr_call_get_summary(
227 __isl_keep pet_expr
*expr
);
228 __isl_give pet_expr
*pet_expr_call_set_summary(__isl_take pet_expr
*expr
,
229 __isl_take pet_function_summary
*summary
);
231 int pet_expr_get_type_size(__isl_keep pet_expr
*expr
);
232 __isl_give pet_expr
*pet_expr_set_type_size(__isl_take pet_expr
*expr
,
234 __isl_give pet_expr
*pet_expr_access_set_depth(__isl_take pet_expr
*expr
,
237 __isl_give pet_expr
*pet_expr_insert_domain(__isl_take pet_expr
*expr
,
238 __isl_take isl_space
*space
);
240 __isl_give pet_expr
*pet_expr_access_patch(__isl_take pet_expr
*expr
,
241 __isl_take isl_multi_pw_aff
*prefix
, int add
);
243 void pet_expr_dump_with_indent(__isl_keep pet_expr
*expr
, int indent
);
245 #if defined(__cplusplus)