extract out the handling of skip conditions
[pet.git] / expr.h
blob674a8b2a43cc2c06fd9610498976098cc0d80a07
1 #ifndef PET_EXPR_H
2 #define PET_EXPR_H
4 #include <pet.h>
6 #if defined(__cplusplus)
7 extern "C" {
8 #endif
10 /* d is valid when type == pet_expr_double
11 * i isl valid when type == pet_expr_int
12 * acc is valid when type == pet_expr_access
13 * name is valid when type == pet_expr_call
14 * type is valid when type == pet_expr_cast
15 * op is valid otherwise
17 * If type_size is not zero, then the expression is of an integer type
18 * and type_size represents the size of the type in bits.
19 * If type_size is greater than zero, then the type is unsigned
20 * and the number of bits is equal to type_size.
21 * If type_size is less than zero, then the type is signed
22 * and the number of bits is equal to -type_size.
23 * type_size may also be zero if the size is (still) unknown.
25 * For each access expression inside the body of a statement, acc.ref_id
26 * is a unique reference identifier.
27 * acc.index represents the index expression, while acc.access
28 * represents the corresponding access relation.
29 * The output dimension of the index expression may be smaller
30 * than the number of dimensions of the accessed array.
31 * The target space of the access relation, on the other hand,
32 * is equal to the array space.
33 * Both acc.index and acc.access usually map an iteration space
34 * to a (partial) data space.
35 * If the access has arguments, however, then the domain of the
36 * mapping is a wrapped mapping from the iteration space
37 * to a space of dimensionality equal to the number of arguments.
38 * Each dimension in this space corresponds to the value of the
39 * corresponding argument.
41 * The ranges of the index expressions and access relations may
42 * also be wrapped relations, in which case the expression represents
43 * a member access, with the structure represented by the domain
44 * of this wrapped relation and the member represented by the range.
45 * In case of nested member accesses, the domain is itself a wrapped
46 * relation.
48 * If the data space is unnamed (and 1D), then it represents
49 * the set of integers. That is, the access represents a value that
50 * is equal to the index.
52 * A double is represented as both an (approximate) value "val" and
53 * a string representation "s".
55 struct pet_expr {
56 int ref;
57 isl_ctx *ctx;
59 enum pet_expr_type type;
61 int type_size;
63 unsigned n_arg;
64 pet_expr **args;
66 union {
67 struct {
68 isl_id *ref_id;
69 isl_map *access;
70 isl_multi_pw_aff *index;
71 int read;
72 int write;
73 } acc;
74 enum pet_op_type op;
75 char *name;
76 char *type_name;
77 struct {
78 double val;
79 char *s;
80 } d;
81 isl_val *i;
85 const char *pet_type_str(enum pet_expr_type type);
86 enum pet_expr_type pet_str_type(const char *str);
88 enum pet_op_type pet_str_op(const char *str);
90 __isl_give pet_expr *pet_expr_alloc(isl_ctx *ctx, enum pet_expr_type type);
91 __isl_give pet_expr *pet_expr_from_index_and_depth(int type_size,
92 __isl_take isl_multi_pw_aff *index, int depth);
93 __isl_give pet_expr *pet_expr_from_access_and_index(__isl_take isl_map *access,
94 __isl_take isl_multi_pw_aff *index);
95 __isl_give pet_expr *pet_expr_kill_from_access_and_index(
96 __isl_take isl_map *access, __isl_take isl_multi_pw_aff *index);
97 __isl_give pet_expr *pet_expr_new_unary(enum pet_op_type op,
98 __isl_take pet_expr *arg);
99 __isl_give pet_expr *pet_expr_new_binary(int type_size, enum pet_op_type op,
100 __isl_take pet_expr *lhs, __isl_take pet_expr *rhs);
101 __isl_give pet_expr *pet_expr_new_ternary(__isl_take pet_expr *cond,
102 __isl_take pet_expr *lhs, __isl_take pet_expr *rhs);
103 __isl_give pet_expr *pet_expr_new_call(isl_ctx *ctx, const char *name,
104 unsigned n_arg);
105 __isl_give pet_expr *pet_expr_new_cast(const char *type_name,
106 __isl_take pet_expr *arg);
107 __isl_give pet_expr *pet_expr_new_double(isl_ctx *ctx, double d, const char *s);
108 __isl_give pet_expr *pet_expr_new_int(__isl_take isl_val *v);
110 __isl_give pet_expr *pet_expr_cow(__isl_take pet_expr *expr);
112 int pet_expr_is_scalar_access(__isl_keep pet_expr *expr);
113 int pet_expr_is_equal(__isl_keep pet_expr *expr1, __isl_keep pet_expr *expr2);
115 __isl_give isl_space *pet_expr_access_get_parameter_space(
116 __isl_take pet_expr *expr);
117 __isl_give isl_space *pet_expr_access_get_data_space(__isl_keep pet_expr *expr);
119 __isl_give pet_expr *pet_expr_map_access(__isl_take pet_expr *expr,
120 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
121 void *user);
123 __isl_give isl_map *pet_expr_access_get_access(__isl_keep pet_expr *expr);
124 __isl_give pet_expr *pet_expr_access_set_access(__isl_take pet_expr *expr,
125 __isl_take isl_map *access);
126 __isl_give pet_expr *pet_expr_access_set_index(__isl_take pet_expr *expr,
127 __isl_take isl_multi_pw_aff *index);
129 int pet_expr_writes(__isl_keep pet_expr *expr, __isl_keep isl_id *id);
131 __isl_give pet_expr *pet_expr_access_move_dims(__isl_take pet_expr *expr,
132 enum isl_dim_type dst_type, unsigned dst_pos,
133 enum isl_dim_type src_type, unsigned src_pos, unsigned n);
134 __isl_give pet_expr *pet_expr_access_pullback_multi_aff(
135 __isl_take pet_expr *expr, __isl_take isl_multi_aff *ma);
136 __isl_give pet_expr *pet_expr_access_align_params(__isl_take pet_expr *expr);
137 __isl_give pet_expr *pet_expr_restrict(__isl_take pet_expr *expr,
138 __isl_take isl_set *cond);
139 __isl_give pet_expr *pet_expr_access_update_domain(__isl_take pet_expr *expr,
140 __isl_keep isl_multi_pw_aff *update);
141 __isl_give pet_expr *pet_expr_update_domain(__isl_take pet_expr *expr,
142 __isl_take isl_multi_pw_aff *update);
143 __isl_give pet_expr *pet_expr_align_params(__isl_take pet_expr *expr,
144 __isl_take isl_space *space);
145 __isl_give pet_expr *pet_expr_filter(__isl_take pet_expr *expr,
146 __isl_take isl_multi_pw_aff *test, int satisfied);
147 __isl_give pet_expr *pet_expr_detect_parameter_accesses(
148 __isl_take pet_expr *expr, __isl_take isl_space *space);
149 __isl_give pet_expr *pet_expr_add_ref_ids(__isl_take pet_expr *expr,
150 int *n_ref);
151 __isl_give pet_expr *pet_expr_anonymize(__isl_take pet_expr *expr);
152 __isl_give pet_expr *pet_expr_gist(__isl_take pet_expr *expr,
153 __isl_keep isl_set *context, __isl_keep isl_union_map *value_bounds);
155 __isl_give isl_map *pet_expr_tag_access(__isl_keep pet_expr *expr,
156 __isl_take isl_map *access);
158 int pet_expr_get_type_size(__isl_keep pet_expr *expr);
159 __isl_give pet_expr *pet_expr_set_type_size(__isl_take pet_expr *expr,
160 int type_size);
162 void pet_expr_dump_with_indent(__isl_keep pet_expr *expr, int indent);
164 #if defined(__cplusplus)
166 #endif
168 #endif