allow parens around integer literal in second argument of integer division
[pet.git] / include / pet.h
blobdf50122b52f51f20e864297312b266d3857e0f85
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_last
50 /* Index into the pet_expr->args array when pet_expr->type == pet_expr_unary
52 enum pet_un_arg_type {
53 pet_un_arg
56 /* Indices into the pet_expr->args array when
57 * pet_expr->type == pet_expr_binary
59 enum pet_bin_arg_type {
60 pet_bin_lhs,
61 pet_bin_rhs
64 /* Indices into the pet_expr->args array when
65 * pet_expr->type == pet_expr_ternary
67 enum pet_ter_arg_type {
68 pet_ter_cond,
69 pet_ter_true,
70 pet_ter_false
73 /* d is valid when type == pet_expr_double
74 * acc is valid when type == pet_expr_access
75 * call is valid when type == pet_expr_call
76 * op is valid otherwise
78 * acc.access usually maps an iteration space to a data space.
79 * If the access has arguments, however, then the domain of the
80 * mapping is a wrapped mapping from the iteration space
81 * to a space of dimensionality equal to the number of arguments.
82 * Each dimension in this space corresponds to the value of the
83 * corresponding argument.
85 * If the data space is unnamed (and 1D), then it represents
86 * the set of integers. That is, the access represents a value that
87 * is equal to the index.
89 struct pet_expr {
90 enum pet_expr_type type;
92 unsigned n_arg;
93 struct pet_expr **args;
95 union {
96 struct {
97 isl_map *access;
98 int read;
99 int write;
100 } acc;
101 enum pet_op_type op;
102 char *name;
103 double d;
107 /* If the statement has arguments, i.e., n_arg != 0, then
108 * "domain" is a wrapped map, mapping the iteration domain
109 * to the values of the arguments for which this statement
110 * is executed.
111 * Otherwise, it is simply the iteration domain.
113 struct pet_stmt {
114 int line;
115 isl_set *domain;
116 isl_map *schedule;
117 struct pet_expr *body;
119 unsigned n_arg;
120 struct pet_expr **args;
123 /* context holds constraints on the parameter that ensure that
124 * this array has a valid (i.e., non-negative) size
126 * extent holds constraints on the indices
128 * value_bounds holds constraints on the elements of the array
129 * and may be NULL if no such constraints were specified by the user
131 * live_out is set if the array appears in a live-out pragma
133 struct pet_array {
134 isl_set *context;
135 isl_set *extent;
136 isl_set *value_bounds;
137 char *element_type;
138 int live_out;
141 /* The context describes the set of parameter values for which
142 * the scop can be executed.
143 * context_value describes assignments to the parameters (if any)
144 * outside of the scop.
146 struct pet_scop {
147 isl_set *context;
148 isl_set *context_value;
150 int n_array;
151 struct pet_array **arrays;
153 int n_stmt;
154 struct pet_stmt **stmts;
157 /* Return a textual representation of the operator. */
158 const char *pet_op_str(enum pet_op_type op);
160 /* Extract a pet_scop from a C source file.
161 * If function is not NULL, then the pet_scop is extracted from
162 * a function with that name.
164 struct pet_scop *pet_scop_extract_from_C_source(isl_ctx *ctx,
165 const char *filename, const char *function);
167 /* Update all isl_sets and isl_maps such that they all have the same
168 * parameters in the same order.
170 struct pet_scop *pet_scop_align_params(struct pet_scop *scop);
172 void pet_scop_dump(struct pet_scop *scop);
173 void *pet_scop_free(struct pet_scop *scop);
175 __isl_give isl_union_set *pet_scop_collect_domains(struct pet_scop *scop);
176 /* Collect all read access relations. */
177 __isl_give isl_union_map *pet_scop_collect_reads(struct pet_scop *scop);
178 /* Collect all write access relations. */
179 __isl_give isl_union_map *pet_scop_collect_writes(struct pet_scop *scop);
180 __isl_give isl_union_map *pet_scop_collect_schedule(struct pet_scop *scop);
182 #if defined(__cplusplus)
184 #endif
186 #endif