Makefile.am: append extra copy of CLANG_LDFLAGS to LDADD
[pet.git] / include / pet.h
blob1b7a98c01c225b2e16d407a9dba40c7c324bcc13
1 #ifndef PET_H
2 #define PET_H
4 #include <isl/set.h>
5 #include <isl/map.h>
6 #include <isl/union_map.h>
8 #if defined(__cplusplus)
9 extern "C" {
10 #endif
12 enum pet_expr_type {
13 pet_expr_access,
14 pet_expr_call,
15 pet_expr_double,
16 pet_expr_unary,
17 pet_expr_binary,
18 pet_expr_ternary
21 enum pet_op_type {
22 /* only compound assignments operators before assignment */
23 pet_op_add_assign,
24 pet_op_sub_assign,
25 pet_op_mul_assign,
26 pet_op_div_assign,
27 pet_op_assign,
28 pet_op_add,
29 pet_op_sub,
30 pet_op_mul,
31 pet_op_div,
32 pet_op_eq,
33 pet_op_le,
34 pet_op_lt,
35 pet_op_gt,
36 pet_op_minus,
37 pet_op_last
40 /* Index into the pet_expr->args array when pet_expr->type == pet_expr_unary
42 enum pet_un_arg_type {
43 pet_un_arg
46 /* Indices into the pet_expr->args array when
47 * pet_expr->type == pet_expr_binary
49 enum pet_bin_arg_type {
50 pet_bin_lhs,
51 pet_bin_rhs
54 /* Indices into the pet_expr->args array when
55 * pet_expr->type == pet_expr_ternary
57 enum pet_ter_arg_type {
58 pet_ter_cond,
59 pet_ter_true,
60 pet_ter_false
63 /* d is valid when type == pet_expr_double
64 * acc is valid when type == pet_expr_access
65 * call is valid when type == pet_expr_call
66 * op is valid otherwise
68 * acc.access usually maps an iteration space to a data space.
69 * If the access has arguments, however, then the domain of the
70 * mapping is a wrapped mapping from the iteration space
71 * to a space of dimensionality equal to the number of arguments.
72 * Each dimension in this space corresponds to the value of the
73 * corresponding argument.
75 * If the data space is unnamed (and 1D), then it represents
76 * the set of integers. That is, the access represents a value that
77 * is equal to the index.
79 struct pet_expr {
80 enum pet_expr_type type;
82 unsigned n_arg;
83 struct pet_expr **args;
85 union {
86 struct {
87 isl_map *access;
88 int read;
89 int write;
90 } acc;
91 enum pet_op_type op;
92 char *name;
93 double d;
97 /* If the statement has arguments, i.e., n_arg != 0, then
98 * "domain" is a wrapped map, mapping the iteration domain
99 * to the values of the arguments for which this statement
100 * is executed.
101 * Otherwise, it is simply the iteration domain.
103 struct pet_stmt {
104 int line;
105 isl_set *domain;
106 isl_map *schedule;
107 struct pet_expr *body;
109 unsigned n_arg;
110 struct pet_expr **args;
113 /* context holds constraints on the parameter that ensure that
114 * this array has a valid (i.e., non-negative) size
116 * extent holds constraints on the indices
118 * value_bounds holds constraints on the elements of the array
119 * and may be NULL if no such constraints were specified by the user
121 * live_out is set if the array appears in a live-out pragma
123 struct pet_array {
124 isl_set *context;
125 isl_set *extent;
126 isl_set *value_bounds;
127 char *element_type;
128 int live_out;
131 /* The context describes the set of parameter values for which
132 * the scop can be executed.
133 * context_value describes assignments to the parameters (if any)
134 * outside of the scop.
136 struct pet_scop {
137 isl_set *context;
138 isl_set *context_value;
140 int n_array;
141 struct pet_array **arrays;
143 int n_stmt;
144 struct pet_stmt **stmts;
147 /* Return a textual representation of the operator. */
148 const char *pet_op_str(enum pet_op_type op);
150 /* Extract a pet_scop from a C source file.
151 * If function is not NULL, then the pet_scop is extracted from
152 * a function with that name.
154 * If autodetect is set, any valid scop is extracted.
155 * Otherwise, the scop needs to be delimited by pragmas.
157 struct pet_scop *pet_scop_extract_from_C_source(isl_ctx *ctx,
158 const char *filename, const char *function, int autodetect);
160 /* Update all isl_sets and isl_maps such that they all have the same
161 * parameters in the same order.
163 struct pet_scop *pet_scop_align_params(struct pet_scop *scop);
165 void pet_scop_dump(struct pet_scop *scop);
166 void *pet_scop_free(struct pet_scop *scop);
168 __isl_give isl_union_set *pet_scop_collect_domains(struct pet_scop *scop);
169 /* Collect all read access relations. */
170 __isl_give isl_union_map *pet_scop_collect_reads(struct pet_scop *scop);
171 /* Collect all write access relations. */
172 __isl_give isl_union_map *pet_scop_collect_writes(struct pet_scop *scop);
173 __isl_give isl_union_map *pet_scop_collect_schedule(struct pet_scop *scop);
175 #if defined(__cplusplus)
177 #endif
179 #endif