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