pet_scop_collect_arrays: collect arrays in a sorted set
[pet.git] / expr.h
blobc3d51548ae2ba8dcef3b3191b9510537f8299962
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 * For each access expression inside the body of a statement, acc.ref_id
18 * is a unique reference identifier.
19 * acc.index represents the index expression, while acc.access
20 * represents the corresponding access relation.
21 * The output dimension of the index expression may be smaller
22 * than the number of dimensions of the accessed array.
23 * The target space of the access relation, on the other hand,
24 * is equal to the array space.
25 * Both acc.index and acc.access usually map an iteration space
26 * to a (partial) data space.
27 * If the access has arguments, however, then the domain of the
28 * mapping is a wrapped mapping from the iteration space
29 * to a space of dimensionality equal to the number of arguments.
30 * Each dimension in this space corresponds to the value of the
31 * corresponding argument.
33 * The ranges of the index expressions and access relations may
34 * also be wrapped relations, in which case the expression represents
35 * a member access, with the structure represented by the domain
36 * of this wrapped relation and the member represented by the range.
37 * In case of nested member accesses, the domain is itself a wrapped
38 * relation.
40 * If the data space is unnamed (and 1D), then it represents
41 * the set of integers. That is, the access represents a value that
42 * is equal to the index.
44 * A double is represented as both an (approximate) value "val" and
45 * a string representation "s".
47 struct pet_expr {
48 int ref;
49 isl_ctx *ctx;
51 enum pet_expr_type type;
53 unsigned n_arg;
54 pet_expr **args;
56 union {
57 struct {
58 isl_id *ref_id;
59 isl_map *access;
60 isl_multi_pw_aff *index;
61 int read;
62 int write;
63 } acc;
64 enum pet_op_type op;
65 char *name;
66 char *type_name;
67 struct {
68 double val;
69 char *s;
70 } d;
71 isl_val *i;
75 const char *pet_type_str(enum pet_expr_type type);
76 enum pet_expr_type pet_str_type(const char *str);
78 enum pet_op_type pet_str_op(const char *str);
80 __isl_give pet_expr *pet_expr_alloc(isl_ctx *ctx, enum pet_expr_type type);
81 __isl_give pet_expr *pet_expr_from_index_and_depth(
82 __isl_take isl_multi_pw_aff *index, int depth);
83 __isl_give pet_expr *pet_expr_from_access_and_index(__isl_take isl_map *access,
84 __isl_take isl_multi_pw_aff *index);
85 __isl_give pet_expr *pet_expr_kill_from_access_and_index(
86 __isl_take isl_map *access, __isl_take isl_multi_pw_aff *index);
87 __isl_give pet_expr *pet_expr_new_unary(enum pet_op_type op,
88 __isl_take pet_expr *arg);
89 __isl_give pet_expr *pet_expr_new_binary(enum pet_op_type op,
90 __isl_take pet_expr *lhs, __isl_take pet_expr *rhs);
91 __isl_give pet_expr *pet_expr_new_ternary(__isl_take pet_expr *cond,
92 __isl_take pet_expr *lhs, __isl_take pet_expr *rhs);
93 __isl_give pet_expr *pet_expr_new_call(isl_ctx *ctx, const char *name,
94 unsigned n_arg);
95 __isl_give pet_expr *pet_expr_new_cast(const char *type_name,
96 __isl_take pet_expr *arg);
97 __isl_give pet_expr *pet_expr_new_double(isl_ctx *ctx, double d, const char *s);
98 __isl_give pet_expr *pet_expr_new_int(__isl_take isl_val *v);
100 __isl_give pet_expr *pet_expr_cow(__isl_take pet_expr *expr);
102 int pet_expr_is_scalar_access(__isl_keep pet_expr *expr);
103 int pet_expr_is_equal(__isl_keep pet_expr *expr1, __isl_keep pet_expr *expr2);
105 __isl_give isl_space *pet_expr_access_get_parameter_space(
106 __isl_take pet_expr *expr);
107 __isl_give isl_space *pet_expr_access_get_data_space(__isl_keep pet_expr *expr);
109 __isl_give pet_expr *pet_expr_map_access(__isl_take pet_expr *expr,
110 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
111 void *user);
113 __isl_give isl_map *pet_expr_access_get_access(__isl_keep pet_expr *expr);
114 __isl_give pet_expr *pet_expr_access_set_access(__isl_take pet_expr *expr,
115 __isl_take isl_map *access);
116 __isl_give pet_expr *pet_expr_access_set_index(__isl_take pet_expr *expr,
117 __isl_take isl_multi_pw_aff *index);
119 int pet_expr_writes(__isl_keep pet_expr *expr, __isl_keep isl_id *id);
121 __isl_give pet_expr *pet_expr_access_move_dims(__isl_take pet_expr *expr,
122 enum isl_dim_type dst_type, unsigned dst_pos,
123 enum isl_dim_type src_type, unsigned src_pos, unsigned n);
124 __isl_give pet_expr *pet_expr_access_pullback_multi_aff(
125 __isl_take pet_expr *expr, __isl_take isl_multi_aff *ma);
126 __isl_give pet_expr *pet_expr_access_align_params(__isl_take pet_expr *expr);
127 __isl_give pet_expr *pet_expr_restrict(__isl_take pet_expr *expr,
128 __isl_take isl_set *cond);
129 __isl_give pet_expr *pet_expr_access_update_domain(__isl_take pet_expr *expr,
130 __isl_keep isl_multi_pw_aff *update);
131 __isl_give pet_expr *pet_expr_update_domain(__isl_take pet_expr *expr,
132 __isl_take isl_multi_pw_aff *update);
133 __isl_give pet_expr *pet_expr_align_params(__isl_take pet_expr *expr,
134 __isl_take isl_space *space);
135 __isl_give pet_expr *pet_expr_filter(__isl_take pet_expr *expr,
136 __isl_take isl_multi_pw_aff *test, int satisfied);
137 __isl_give pet_expr *pet_expr_detect_parameter_accesses(
138 __isl_take pet_expr *expr, __isl_take isl_space *space);
139 __isl_give pet_expr *pet_expr_add_ref_ids(__isl_take pet_expr *expr,
140 int *n_ref);
141 __isl_give pet_expr *pet_expr_anonymize(__isl_take pet_expr *expr);
142 __isl_give pet_expr *pet_expr_gist(__isl_take pet_expr *expr,
143 __isl_keep isl_set *context, __isl_keep isl_union_map *value_bounds);
145 __isl_give isl_map *pet_expr_tag_access(__isl_keep pet_expr *expr,
146 __isl_take isl_map *access);
148 void pet_expr_dump_with_indent(__isl_keep pet_expr *expr, int indent);
150 #if defined(__cplusplus)
152 #endif
154 #endif