update for change in clang's HeaderSearchOptions
[pet.git] / include / pet.h
blob3938c450d791cd3bbec4aefa3743c20e904f45ae
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 #define PET_OVERFLOW_AVOID 0
23 #define PET_OVERFLOW_IGNORE 1
24 int pet_options_set_signed_overflow(isl_ctx *ctx, int val);
25 int pet_options_get_signed_overflow(isl_ctx *ctx);
27 enum pet_expr_type {
28 pet_expr_access,
29 pet_expr_call,
30 pet_expr_double,
31 pet_expr_unary,
32 pet_expr_binary,
33 pet_expr_ternary
36 enum pet_op_type {
37 /* only compound assignments operators before assignment */
38 pet_op_add_assign,
39 pet_op_sub_assign,
40 pet_op_mul_assign,
41 pet_op_div_assign,
42 pet_op_assign,
43 pet_op_add,
44 pet_op_sub,
45 pet_op_mul,
46 pet_op_div,
47 pet_op_mod,
48 pet_op_eq,
49 pet_op_le,
50 pet_op_lt,
51 pet_op_gt,
52 pet_op_minus,
53 pet_op_post_inc,
54 pet_op_post_dec,
55 pet_op_pre_inc,
56 pet_op_pre_dec,
57 pet_op_address_of,
58 pet_op_last
61 /* Index into the pet_expr->args array when pet_expr->type == pet_expr_unary
63 enum pet_un_arg_type {
64 pet_un_arg
67 /* Indices into the pet_expr->args array when
68 * pet_expr->type == pet_expr_binary
70 enum pet_bin_arg_type {
71 pet_bin_lhs,
72 pet_bin_rhs
75 /* Indices into the pet_expr->args array when
76 * pet_expr->type == pet_expr_ternary
78 enum pet_ter_arg_type {
79 pet_ter_cond,
80 pet_ter_true,
81 pet_ter_false
84 /* d is valid when type == pet_expr_double
85 * acc is valid when type == pet_expr_access
86 * name is valid when type == pet_expr_call
87 * op is valid otherwise
89 * acc.access usually maps an iteration space to a data space.
90 * If the access has arguments, however, then the domain of the
91 * mapping is a wrapped mapping from the iteration space
92 * to a space of dimensionality equal to the number of arguments.
93 * Each dimension in this space corresponds to the value of the
94 * corresponding argument.
96 * If the data space is unnamed (and 1D), then it represents
97 * the set of integers. That is, the access represents a value that
98 * is equal to the index.
100 struct pet_expr {
101 enum pet_expr_type type;
103 unsigned n_arg;
104 struct pet_expr **args;
106 union {
107 struct {
108 isl_map *access;
109 int read;
110 int write;
111 } acc;
112 enum pet_op_type op;
113 char *name;
114 double d;
118 /* If the statement has arguments, i.e., n_arg != 0, then
119 * "domain" is a wrapped map, mapping the iteration domain
120 * to the values of the arguments for which this statement
121 * is executed.
122 * Otherwise, it is simply the iteration domain.
124 * If one of the arguments is an access expression that accesses
125 * more than one element for a given iteration, then the constraints
126 * on the value of this argument (encoded in "domain") should be satisfied
127 * for all of those accessed elements.
129 struct pet_stmt {
130 int line;
131 isl_set *domain;
132 isl_map *schedule;
133 struct pet_expr *body;
135 unsigned n_arg;
136 struct pet_expr **args;
139 /* context holds constraints on the parameter that ensure that
140 * this array has a valid (i.e., non-negative) size
142 * extent holds constraints on the indices
144 * value_bounds holds constraints on the elements of the array
145 * and may be NULL if no such constraints were specified by the user
147 * element_size is the size in bytes of each array element
149 * live_out is set if the array appears in a live-out pragma
151 * if uniquely_defined is set then the array is written by a single access
152 * such that any element that is ever read
153 * is known to be assigned exactly once before the read
155 struct pet_array {
156 isl_set *context;
157 isl_set *extent;
158 isl_set *value_bounds;
159 char *element_type;
160 int element_size;
161 int live_out;
162 int uniquely_defined;
165 /* The context describes the set of parameter values for which
166 * the scop can be executed.
167 * context_value describes assignments to the parameters (if any)
168 * outside of the scop.
170 struct pet_scop {
171 isl_set *context;
172 isl_set *context_value;
174 int n_array;
175 struct pet_array **arrays;
177 int n_stmt;
178 struct pet_stmt **stmts;
181 /* Return a textual representation of the operator. */
182 const char *pet_op_str(enum pet_op_type op);
183 int pet_op_is_inc_dec(enum pet_op_type op);
185 /* Extract a pet_scop from a C source file.
186 * If function is not NULL, then the pet_scop is extracted from
187 * a function with that name.
189 struct pet_scop *pet_scop_extract_from_C_source(isl_ctx *ctx,
190 const char *filename, const char *function);
192 /* Update all isl_sets and isl_maps such that they all have the same
193 * parameters in the same order.
195 struct pet_scop *pet_scop_align_params(struct pet_scop *scop);
197 void pet_scop_dump(struct pet_scop *scop);
198 void *pet_scop_free(struct pet_scop *scop);
200 __isl_give isl_union_set *pet_scop_collect_domains(struct pet_scop *scop);
201 /* Collect all read access relations. */
202 __isl_give isl_union_map *pet_scop_collect_reads(struct pet_scop *scop);
203 /* Collect all write access relations. */
204 __isl_give isl_union_map *pet_scop_collect_writes(struct pet_scop *scop);
205 __isl_give isl_union_map *pet_scop_collect_schedule(struct pet_scop *scop);
207 #if defined(__cplusplus)
209 #endif
211 #endif