README: update to latest release of clang
[pet.git] / include / pet.h
blobb88d84e69f1ad758638f738f3781ea286802a741
1 #ifndef PET_H
2 #define PET_H
4 #include <isl/arg.h>
5 #include <isl/set.h>
6 #include <isl/map.h>
7 #include <isl/union_map.h>
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
13 struct pet_options;
14 ISL_ARG_DECL(pet_options, struct pet_options, pet_options_args)
16 /* If autodetect is set, any valid scop is extracted.
17 * Otherwise, the scop needs to be delimited by pragmas.
19 int pet_options_set_autodetect(isl_ctx *ctx, int val);
20 int pet_options_get_autodetect(isl_ctx *ctx);
22 enum pet_expr_type {
23 pet_expr_access,
24 pet_expr_call,
25 pet_expr_double,
26 pet_expr_unary,
27 pet_expr_binary,
28 pet_expr_ternary
31 enum pet_op_type {
32 /* only compound assignments operators before assignment */
33 pet_op_add_assign,
34 pet_op_sub_assign,
35 pet_op_mul_assign,
36 pet_op_div_assign,
37 pet_op_assign,
38 pet_op_add,
39 pet_op_sub,
40 pet_op_mul,
41 pet_op_div,
42 pet_op_eq,
43 pet_op_le,
44 pet_op_lt,
45 pet_op_gt,
46 pet_op_minus,
47 pet_op_post_inc,
48 pet_op_post_dec,
49 pet_op_pre_inc,
50 pet_op_pre_dec,
51 pet_op_address_of,
52 pet_op_last
55 /* Index into the pet_expr->args array when pet_expr->type == pet_expr_unary
57 enum pet_un_arg_type {
58 pet_un_arg
61 /* Indices into the pet_expr->args array when
62 * pet_expr->type == pet_expr_binary
64 enum pet_bin_arg_type {
65 pet_bin_lhs,
66 pet_bin_rhs
69 /* Indices into the pet_expr->args array when
70 * pet_expr->type == pet_expr_ternary
72 enum pet_ter_arg_type {
73 pet_ter_cond,
74 pet_ter_true,
75 pet_ter_false
78 /* d is valid when type == pet_expr_double
79 * acc is valid when type == pet_expr_access
80 * call is valid when type == pet_expr_call
81 * op is valid otherwise
83 * acc.access usually maps an iteration space to a data space.
84 * If the access has arguments, however, then the domain of the
85 * mapping is a wrapped mapping from the iteration space
86 * to a space of dimensionality equal to the number of arguments.
87 * Each dimension in this space corresponds to the value of the
88 * corresponding argument.
90 * If the data space is unnamed (and 1D), then it represents
91 * the set of integers. That is, the access represents a value that
92 * is equal to the index.
94 struct pet_expr {
95 enum pet_expr_type type;
97 unsigned n_arg;
98 struct pet_expr **args;
100 union {
101 struct {
102 isl_map *access;
103 int read;
104 int write;
105 } acc;
106 enum pet_op_type op;
107 char *name;
108 double d;
112 /* If the statement has arguments, i.e., n_arg != 0, then
113 * "domain" is a wrapped map, mapping the iteration domain
114 * to the values of the arguments for which this statement
115 * is executed.
116 * Otherwise, it is simply the iteration domain.
118 * If one of the arguments is an access expression that accesses
119 * more than one element for a given iteration, then the constraints
120 * on the value of this argument (encoded in "domain") should be satisfied
121 * for all of those accessed elements.
123 struct pet_stmt {
124 int line;
125 isl_set *domain;
126 isl_map *schedule;
127 struct pet_expr *body;
129 unsigned n_arg;
130 struct pet_expr **args;
133 /* context holds constraints on the parameter that ensure that
134 * this array has a valid (i.e., non-negative) size
136 * extent holds constraints on the indices
138 * value_bounds holds constraints on the elements of the array
139 * and may be NULL if no such constraints were specified by the user
141 * element_size is the size in bytes of each array element
143 * live_out is set if the array appears in a live-out pragma
145 * if uniquely_defined is set then the array is written by a single access
146 * such that any element that is ever read
147 * is known to be assigned exactly once before the read
149 struct pet_array {
150 isl_set *context;
151 isl_set *extent;
152 isl_set *value_bounds;
153 char *element_type;
154 int element_size;
155 int live_out;
156 int uniquely_defined;
159 /* The context describes the set of parameter values for which
160 * the scop can be executed.
161 * context_value describes assignments to the parameters (if any)
162 * outside of the scop.
164 struct pet_scop {
165 isl_set *context;
166 isl_set *context_value;
168 int n_array;
169 struct pet_array **arrays;
171 int n_stmt;
172 struct pet_stmt **stmts;
175 /* Return a textual representation of the operator. */
176 const char *pet_op_str(enum pet_op_type op);
177 int pet_op_is_inc_dec(enum pet_op_type op);
179 /* Extract a pet_scop from a C source file.
180 * If function is not NULL, then the pet_scop is extracted from
181 * a function with that name.
183 struct pet_scop *pet_scop_extract_from_C_source(isl_ctx *ctx,
184 const char *filename, const char *function);
186 /* Update all isl_sets and isl_maps such that they all have the same
187 * parameters in the same order.
189 struct pet_scop *pet_scop_align_params(struct pet_scop *scop);
191 void pet_scop_dump(struct pet_scop *scop);
192 void *pet_scop_free(struct pet_scop *scop);
194 __isl_give isl_union_set *pet_scop_collect_domains(struct pet_scop *scop);
195 /* Collect all read access relations. */
196 __isl_give isl_union_map *pet_scop_collect_reads(struct pet_scop *scop);
197 /* Collect all write access relations. */
198 __isl_give isl_union_map *pet_scop_collect_writes(struct pet_scop *scop);
199 __isl_give isl_union_map *pet_scop_collect_schedule(struct pet_scop *scop);
201 #if defined(__cplusplus)
203 #endif
205 #endif