PetScan::extract_nested: plug memory leak on error path
[pet.git] / scop.h
blob1c9d7158397b48d3bc8965abfa115ed3bd4b80d3
1 #ifndef PET_SCOP_H
2 #define PET_SCOP_H
4 #include <pet.h>
6 #include <isl/aff.h>
7 #include <isl/id.h>
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
13 /* Do we want to skip the rest of the current loop iteration (pet_skip_now)
14 * or subsequent loop iterations (pet_skip_later)?
16 enum pet_skip { pet_skip_now = 0, pet_skip_later = 1 };
18 const char *pet_type_str(enum pet_expr_type type);
19 enum pet_expr_type pet_str_type(const char *str);
21 enum pet_op_type pet_str_op(const char *str);
23 struct pet_expr *pet_expr_from_index(__isl_take isl_multi_pw_aff *index);
24 struct pet_expr *pet_expr_from_index_and_depth(
25 __isl_take isl_multi_pw_aff *index, int depth);
26 struct pet_expr *pet_expr_from_access_and_index(__isl_take isl_map *access,
27 __isl_take isl_multi_pw_aff *index);
28 struct pet_expr *pet_expr_kill_from_access_and_index(__isl_take isl_map *access,
29 __isl_take isl_multi_pw_aff *index);
30 struct pet_expr *pet_expr_new_unary(isl_ctx *ctx, enum pet_op_type op,
31 struct pet_expr *arg);
32 struct pet_expr *pet_expr_new_binary(isl_ctx *ctx, enum pet_op_type op,
33 struct pet_expr *lhs, struct pet_expr *rhs);
34 struct pet_expr *pet_expr_new_ternary(isl_ctx *ctx, struct pet_expr *cond,
35 struct pet_expr *lhs, struct pet_expr *rhs);
36 struct pet_expr *pet_expr_new_call(isl_ctx *ctx, const char *name,
37 unsigned n_arg);
38 struct pet_expr *pet_expr_new_cast(isl_ctx *ctx, const char *type_name,
39 struct pet_expr *arg);
40 struct pet_expr *pet_expr_new_double(isl_ctx *ctx, double d, const char *s);
41 void pet_expr_dump(struct pet_expr *expr);
42 struct pet_expr *pet_expr_free(struct pet_expr *expr);
44 int pet_expr_is_affine(struct pet_expr *expr);
45 __isl_give isl_id *pet_expr_access_get_id(struct pet_expr *expr);
46 struct pet_expr *pet_expr_access_align_params(struct pet_expr *expr);
47 int pet_expr_is_scalar_access(struct pet_expr *expr);
48 int pet_expr_is_equal(struct pet_expr *expr1, struct pet_expr *expr2);
49 struct pet_expr *pet_expr_restrict(struct pet_expr *expr,
50 __isl_take isl_set *cond);
52 struct pet_stmt *pet_stmt_from_pet_expr(isl_ctx *ctx, int line,
53 __isl_take isl_id *label, int id, struct pet_expr *expr);
54 void pet_stmt_dump(struct pet_stmt *stmt);
55 void *pet_stmt_free(struct pet_stmt *stmt);
57 int pet_stmt_is_assume(struct pet_stmt *stmt);
59 struct pet_type *pet_type_alloc(isl_ctx *ctx, const char *name,
60 const char *definition);
61 struct pet_type *pet_type_free(struct pet_type *type);
63 void pet_array_dump(struct pet_array *array);
64 struct pet_array *pet_array_free(struct pet_array *array);
66 void *pet_implication_free(struct pet_implication *implication);
68 struct pet_stmt *pet_stmt_prefix(struct pet_stmt *stmt, int pos);
70 struct pet_scop *pet_scop_from_pet_stmt(isl_ctx *ctx, struct pet_stmt *stmt);
71 struct pet_scop *pet_scop_alloc(isl_ctx *ctx);
72 struct pet_scop *pet_scop_empty(isl_ctx *ctx);
73 struct pet_scop *pet_scop_add_seq(isl_ctx *ctx, struct pet_scop *scop1,
74 struct pet_scop *scop2);
75 struct pet_scop *pet_scop_add_par(isl_ctx *ctx, struct pet_scop *scop1,
76 struct pet_scop *scop2);
78 int pet_scop_is_equal(struct pet_scop *scop1, struct pet_scop *scop2);
80 struct pet_scop *pet_scop_prefix(struct pet_scop *scop, int pos);
81 struct pet_scop *pet_scop_embed(struct pet_scop *scop, __isl_take isl_set *dom,
82 __isl_take isl_map *sched, __isl_take isl_aff *iv_map,
83 __isl_take isl_id *id);
84 struct pet_scop *pet_scop_restrict(struct pet_scop *scop,
85 __isl_take isl_set *cond);
86 struct pet_scop *pet_scop_restrict_context(struct pet_scop *scop,
87 __isl_take isl_set *context);
88 struct pet_scop *pet_scop_reset_context(struct pet_scop *scop);
89 struct pet_expr *pet_expr_filter(struct pet_expr *expr,
90 __isl_take isl_multi_pw_aff *test, int satisfied);
91 struct pet_scop *pet_scop_filter(struct pet_scop *scop,
92 __isl_take isl_multi_pw_aff *test, int satisfied);
93 struct pet_scop *pet_scop_merge_filters(struct pet_scop *scop);
94 struct pet_scop *pet_scop_add_implication(struct pet_scop *scop,
95 __isl_take isl_map *map, int satisfied);
97 struct pet_scop *pet_scop_detect_parameter_accesses(struct pet_scop *scop);
99 struct pet_scop *pet_scop_gist(struct pet_scop *scop,
100 __isl_keep isl_union_map *value_bounds);
102 struct pet_scop *pet_scop_add_ref_ids(struct pet_scop *scop);
103 struct pet_scop *pet_scop_anonymize(struct pet_scop *scop);
105 int pet_expr_foreach_access_expr(struct pet_expr *expr,
106 int (*fn)(struct pet_expr *expr, void *user), void *user);
107 struct pet_expr *pet_expr_map_access(struct pet_expr *expr,
108 struct pet_expr *(*fn)(struct pet_expr *expr, void *user),
109 void *user);
111 int pet_scop_writes(struct pet_scop *scop, __isl_keep isl_id *id);
113 int pet_scop_has_skip(struct pet_scop *scop, enum pet_skip type);
114 int pet_scop_has_affine_skip(struct pet_scop *scop, enum pet_skip type);
115 int pet_scop_has_universal_skip(struct pet_scop *scop, enum pet_skip type);
116 int pet_scop_has_var_skip(struct pet_scop *scop, enum pet_skip type);
117 struct pet_scop *pet_scop_set_skip(struct pet_scop *scop,
118 enum pet_skip type, __isl_take isl_multi_pw_aff *skip);
119 __isl_give isl_multi_pw_aff *pet_scop_get_skip(struct pet_scop *scop,
120 enum pet_skip type);
121 __isl_give isl_set *pet_scop_get_affine_skip_domain(struct pet_scop *scop,
122 enum pet_skip type);
123 __isl_give isl_id *pet_scop_get_skip_id(struct pet_scop *scop,
124 enum pet_skip type);
125 struct pet_expr *pet_scop_get_skip_expr(struct pet_scop *scop,
126 enum pet_skip type);
127 void pet_scop_reset_skip(struct pet_scop *scop, enum pet_skip type);
129 struct pet_scop *pet_scop_add_array(struct pet_scop *scop,
130 struct pet_array *array);
132 struct pet_scop *pet_scop_update_start_end(struct pet_scop *scop,
133 unsigned start, unsigned end);
134 struct pet_scop *pet_scop_set_input_file(struct pet_scop *scop, FILE *input);
136 #if defined(__cplusplus)
138 #endif
140 #endif