update isl for isl_schedule_gist_domain_params
[pet.git] / expr.h
blob468d0cf3f9a9d252a6ed454951d307751337e00b
1 #ifndef PET_EXPR_H
2 #define PET_EXPR_H
4 #include <pet.h>
6 #include "context.h"
7 #include "expr_access_type.h"
8 #include "summary.h"
10 #if defined(__cplusplus)
11 extern "C" {
12 #endif
14 /* d is valid when type == pet_expr_double
15 * i isl valid when type == pet_expr_int
16 * acc is valid when type == pet_expr_access
17 * c is valid when type == pet_expr_call
18 * type is valid when type == pet_expr_cast
19 * op is valid otherwise
21 * If type_size is not zero, then the expression is of an integer type
22 * and type_size represents the size of the type in bits.
23 * If type_size is greater than zero, then the type is unsigned
24 * and the number of bits is equal to type_size.
25 * If type_size is less than zero, then the type is signed
26 * and the number of bits is equal to -type_size.
27 * type_size may also be zero if the size is (still) unknown.
29 * For each access expression inside the body of a statement, acc.ref_id
30 * is a unique reference identifier.
31 * acc.index represents the index expression, while acc.access
32 * represents the corresponding access relations.
33 * The output dimension of the index expression may be smaller
34 * than the number of dimensions of the accessed array (recorded
35 * in acc.depth).
36 * The target space of the access relation, on the other hand,
37 * is equal to the array space.
38 * The entries in acc.access may be NULL if they can be derived directly from
39 * acc.index and acc.depth in construct_access_relation or if they are
40 * irrelevant for the given type of access.
41 * In particular, the entries of acc.access may be NULL if there are
42 * no additional constraints on the access relations.
43 * Both acc.index and the acc.access entries usually map an iteration space
44 * to a (partial) data space.
45 * If the access has arguments, however, then the domain of the
46 * mapping is a wrapped mapping from the iteration space
47 * to a space of dimensionality equal to the number of arguments.
48 * Each dimension in this space corresponds to the value of the
49 * corresponding argument.
51 * The ranges of the index expressions and access relations may
52 * also be wrapped relations, in which case the expression represents
53 * a member access, with the structure represented by the domain
54 * of this wrapped relation and the member represented by the range.
55 * In case of nested member accesses, the domain is itself a wrapped
56 * relation.
58 * If the data space is unnamed (and 1D), then it represents
59 * the set of integers. That is, the access represents a value that
60 * is equal to the index.
62 * An access expresssion is marked "read" if it represents a read and
63 * marked "write" if it represents a write. A single access expression
64 * may be marked both read and write.
65 * Alternatively, the expression may be marked "kill", in which case it
66 * is the argument of a kill operation and represents the set of
67 * killed array elements. Such accesses are marked neither read nor write.
68 * Since a kill can never be a read (or a write), the killed access
69 * relation is stored in the same location as the may read access relation.
71 * A function call is represented by the name of the called function and
72 * an optional function summary (the value NULL indicating that there is
73 * no function summary).
75 * A double is represented as both an (approximate) value "val" and
76 * a string representation "s".
78 struct pet_expr {
79 int ref;
80 isl_ctx *ctx;
82 enum pet_expr_type type;
84 int type_size;
86 unsigned n_arg;
87 pet_expr **args;
89 union {
90 struct {
91 isl_id *ref_id;
92 isl_multi_pw_aff *index;
93 int depth;
94 unsigned read : 1;
95 unsigned write : 1;
96 unsigned kill : 1;
97 isl_union_map *access[pet_expr_access_end];
98 } acc;
99 enum pet_op_type op;
100 struct {
101 char *name;
102 pet_function_summary *summary;
103 } c;
104 char *type_name;
105 struct {
106 double val;
107 char *s;
108 } d;
109 isl_val *i;
113 const char *pet_type_str(enum pet_expr_type type);
114 enum pet_expr_type pet_str_type(const char *str);
116 enum pet_op_type pet_str_op(const char *str);
118 __isl_give pet_expr *pet_expr_alloc(isl_ctx *ctx, enum pet_expr_type type);
119 __isl_give pet_expr *pet_expr_kill_from_access_and_index(
120 __isl_take isl_map *access, __isl_take isl_multi_pw_aff *index);
121 __isl_give pet_expr *pet_expr_new_unary(int type_size, enum pet_op_type op,
122 __isl_take pet_expr *arg);
123 __isl_give pet_expr *pet_expr_new_binary(int type_size, enum pet_op_type op,
124 __isl_take pet_expr *lhs, __isl_take pet_expr *rhs);
125 __isl_give pet_expr *pet_expr_new_ternary(__isl_take pet_expr *cond,
126 __isl_take pet_expr *lhs, __isl_take pet_expr *rhs);
127 __isl_give pet_expr *pet_expr_new_call(isl_ctx *ctx, const char *name,
128 unsigned n_arg);
129 __isl_give pet_expr *pet_expr_new_double(isl_ctx *ctx, double d, const char *s);
130 __isl_give pet_expr *pet_expr_new_int(__isl_take isl_val *v);
132 __isl_give pet_expr *pet_expr_cow(__isl_take pet_expr *expr);
134 __isl_give isl_pw_aff *pet_expr_extract_affine_condition(
135 __isl_keep pet_expr *expr, __isl_keep pet_context *pc);
136 __isl_give isl_pw_aff *pet_expr_extract_comparison(enum pet_op_type op,
137 __isl_keep pet_expr *lhs, __isl_keep pet_expr *rhs,
138 __isl_keep pet_context *pc);
139 __isl_give pet_expr *pet_expr_resolve_assume(__isl_take pet_expr *expr,
140 __isl_keep pet_context *pc);
142 int pet_expr_is_assume(__isl_keep pet_expr *expr);
143 int pet_expr_is_boolean(__isl_keep pet_expr *expr);
144 int pet_expr_is_comparison(__isl_keep pet_expr *expr);
145 int pet_expr_is_min(__isl_keep pet_expr *expr);
146 int pet_expr_is_max(__isl_keep pet_expr *expr);
147 int pet_expr_is_scalar_access(__isl_keep pet_expr *expr);
148 int pet_expr_is_equal(__isl_keep pet_expr *expr1, __isl_keep pet_expr *expr2);
150 __isl_give isl_space *pet_expr_access_get_parameter_space(
151 __isl_take pet_expr *expr);
152 __isl_give isl_space *pet_expr_access_get_augmented_domain_space(
153 __isl_keep pet_expr *expr);
154 __isl_give isl_space *pet_expr_access_get_domain_space(
155 __isl_keep pet_expr *expr);
156 __isl_give isl_space *pet_expr_access_get_data_space(__isl_keep pet_expr *expr);
158 __isl_give isl_union_map *pet_expr_access_get_dependent_access(
159 __isl_keep pet_expr *expr, enum pet_expr_access_type type);
160 __isl_give isl_map *pet_expr_access_get_may_access(__isl_keep pet_expr *expr);
162 __isl_give pet_expr *pet_expr_map_access(__isl_take pet_expr *expr,
163 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
164 void *user);
165 __isl_give pet_expr *pet_expr_map_call(__isl_take pet_expr *expr,
166 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
167 void *user);
169 __isl_give isl_union_map *pet_expr_access_get_access(__isl_keep pet_expr *expr,
170 enum pet_expr_access_type type);
171 __isl_give pet_expr *pet_expr_access_set_access(__isl_take pet_expr *expr,
172 enum pet_expr_access_type type, __isl_take isl_union_map *access);
173 __isl_give pet_expr *pet_expr_access_set_index(__isl_take pet_expr *expr,
174 __isl_take isl_multi_pw_aff *index);
176 int pet_expr_is_sub_access(__isl_keep pet_expr *expr1,
177 __isl_keep pet_expr *expr2, int n_arg);
179 int pet_expr_writes(__isl_keep pet_expr *expr, __isl_keep isl_id *id);
181 __isl_give pet_expr *pet_expr_access_move_dims(__isl_take pet_expr *expr,
182 enum isl_dim_type dst_type, unsigned dst_pos,
183 enum isl_dim_type src_type, unsigned src_pos, unsigned n);
184 __isl_give pet_expr *pet_expr_access_pullback_multi_aff(
185 __isl_take pet_expr *expr, __isl_take isl_multi_aff *ma);
186 __isl_give pet_expr *pet_expr_access_pullback_multi_pw_aff(
187 __isl_take pet_expr *expr, __isl_take isl_multi_pw_aff *mpa);
188 __isl_give pet_expr *pet_expr_access_align_params(__isl_take pet_expr *expr);
189 __isl_give pet_expr *pet_expr_restrict(__isl_take pet_expr *expr,
190 __isl_take isl_set *cond);
191 __isl_give pet_expr *pet_expr_access_update_domain(__isl_take pet_expr *expr,
192 __isl_keep isl_multi_pw_aff *update);
193 __isl_give pet_expr *pet_expr_update_domain(__isl_take pet_expr *expr,
194 __isl_take isl_multi_pw_aff *update);
195 __isl_give pet_expr *pet_expr_align_params(__isl_take pet_expr *expr,
196 __isl_take isl_space *space);
197 __isl_give pet_expr *pet_expr_filter(__isl_take pet_expr *expr,
198 __isl_take isl_multi_pw_aff *test, int satisfied);
199 __isl_give pet_expr *pet_expr_add_ref_ids(__isl_take pet_expr *expr,
200 int *n_ref);
201 __isl_give pet_expr *pet_expr_anonymize(__isl_take pet_expr *expr);
202 __isl_give pet_expr *pet_expr_gist(__isl_take pet_expr *expr,
203 __isl_keep isl_set *context, __isl_keep isl_union_map *value_bounds);
205 __isl_give isl_union_map *pet_expr_tag_access(__isl_keep pet_expr *expr,
206 __isl_take isl_union_map *access);
208 __isl_give pet_expr *pet_expr_access_subscript(__isl_take pet_expr *base,
209 __isl_take pet_expr *index);
210 __isl_give pet_expr *pet_expr_access_member(__isl_take pet_expr *base,
211 __isl_take isl_id *member);
213 int pet_expr_call_has_summary(__isl_keep pet_expr *expr);
214 __isl_give pet_function_summary *pet_expr_call_get_summary(
215 __isl_keep pet_expr *expr);
216 __isl_give pet_expr *pet_expr_call_set_summary(__isl_take pet_expr *expr,
217 __isl_take pet_function_summary *summary);
219 int pet_expr_get_type_size(__isl_keep pet_expr *expr);
220 __isl_give pet_expr *pet_expr_set_type_size(__isl_take pet_expr *expr,
221 int type_size);
222 __isl_give pet_expr *pet_expr_access_set_depth(__isl_take pet_expr *expr,
223 int depth);
225 __isl_give pet_expr *pet_expr_insert_domain(__isl_take pet_expr *expr,
226 __isl_take isl_space *space);
228 void pet_expr_dump_with_indent(__isl_keep pet_expr *expr, int indent);
230 #if defined(__cplusplus)
232 #endif
234 #endif