pet.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. #ifndef PET_H
  2. #define PET_H
  3. #include <isl/aff.h>
  4. #include <isl/arg.h>
  5. #include <isl/ast_build.h>
  6. #include <isl/set.h>
  7. #include <isl/map.h>
  8. #include <isl/union_map.h>
  9. #include <isl/printer.h>
  10. #include <isl/id_to_ast_expr.h>
  11. #include <isl/id_to_pw_aff.h>
  12. #include <isl/schedule.h>
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. struct pet_options;
  17. ISL_ARG_DECL(pet_options, struct pet_options, pet_options_args)
  18. /* Create an isl_ctx that references the pet options. */
  19. isl_ctx *isl_ctx_alloc_with_pet_options();
  20. /* If autodetect is set, any valid scop is extracted.
  21. * Otherwise, the scop needs to be delimited by pragmas.
  22. */
  23. int pet_options_set_autodetect(isl_ctx *ctx, int val);
  24. int pet_options_get_autodetect(isl_ctx *ctx);
  25. int pet_options_set_detect_conditional_assignment(isl_ctx *ctx, int val);
  26. int pet_options_get_detect_conditional_assignment(isl_ctx *ctx);
  27. /* If encapsulate-dynamic-control is set, then any dynamic control
  28. * in the input program will be encapsulated in macro statements.
  29. * This means in particular that no statements with arguments
  30. * will be created.
  31. */
  32. int pet_options_set_encapsulate_dynamic_control(isl_ctx *ctx, int val);
  33. int pet_options_get_encapsulate_dynamic_control(isl_ctx *ctx);
  34. #define PET_OVERFLOW_AVOID 0
  35. #define PET_OVERFLOW_IGNORE 1
  36. int pet_options_set_signed_overflow(isl_ctx *ctx, int val);
  37. int pet_options_get_signed_overflow(isl_ctx *ctx);
  38. struct pet_loc;
  39. typedef struct pet_loc pet_loc;
  40. /* Return an additional reference to "loc". */
  41. __isl_give pet_loc *pet_loc_copy(__isl_keep pet_loc *loc);
  42. /* Free a reference to "loc". */
  43. pet_loc *pet_loc_free(__isl_take pet_loc *loc);
  44. /* Return the offset in the input file of the start of "loc". */
  45. unsigned pet_loc_get_start(__isl_keep pet_loc *loc);
  46. /* Return the offset in the input file of the character after "loc". */
  47. unsigned pet_loc_get_end(__isl_keep pet_loc *loc);
  48. /* Return the line number of a line within the "loc" region. */
  49. int pet_loc_get_line(__isl_keep pet_loc *loc);
  50. /* Return the indentation of the "loc" region. */
  51. __isl_keep const char *pet_loc_get_indent(__isl_keep pet_loc *loc);
  52. enum pet_expr_type {
  53. pet_expr_error = -1,
  54. pet_expr_access,
  55. pet_expr_call,
  56. pet_expr_cast,
  57. pet_expr_int,
  58. pet_expr_double,
  59. pet_expr_op
  60. };
  61. enum pet_op_type {
  62. /* only compound assignments operators before assignment */
  63. pet_op_add_assign,
  64. pet_op_sub_assign,
  65. pet_op_mul_assign,
  66. pet_op_div_assign,
  67. pet_op_and_assign,
  68. pet_op_xor_assign,
  69. pet_op_or_assign,
  70. pet_op_assign,
  71. pet_op_add,
  72. pet_op_sub,
  73. pet_op_mul,
  74. pet_op_div,
  75. pet_op_mod,
  76. pet_op_shl,
  77. pet_op_shr,
  78. pet_op_eq,
  79. pet_op_ne,
  80. pet_op_le,
  81. pet_op_ge,
  82. pet_op_lt,
  83. pet_op_gt,
  84. pet_op_minus,
  85. pet_op_post_inc,
  86. pet_op_post_dec,
  87. pet_op_pre_inc,
  88. pet_op_pre_dec,
  89. pet_op_address_of,
  90. pet_op_assume,
  91. pet_op_kill,
  92. pet_op_and,
  93. pet_op_xor,
  94. pet_op_or,
  95. pet_op_not,
  96. pet_op_land,
  97. pet_op_lor,
  98. pet_op_lnot,
  99. pet_op_cond,
  100. pet_op_last
  101. };
  102. /* Index into the pet_expr->args array when pet_expr->type == pet_expr_unary
  103. */
  104. enum pet_un_arg_type {
  105. pet_un_arg
  106. };
  107. /* Indices into the pet_expr->args array when
  108. * pet_expr->type == pet_expr_binary
  109. */
  110. enum pet_bin_arg_type {
  111. pet_bin_lhs,
  112. pet_bin_rhs
  113. };
  114. /* Indices into the pet_expr->args array when
  115. * pet_expr->type == pet_expr_ternary
  116. */
  117. enum pet_ter_arg_type {
  118. pet_ter_cond,
  119. pet_ter_true,
  120. pet_ter_false
  121. };
  122. struct pet_expr;
  123. typedef struct pet_expr pet_expr;
  124. /* Return an additional reference to "expr". */
  125. __isl_give pet_expr *pet_expr_copy(__isl_keep pet_expr *expr);
  126. /* Free a reference to "expr". */
  127. __isl_null pet_expr *pet_expr_free(__isl_take pet_expr *expr);
  128. /* Return the isl_ctx in which "expr" was created. */
  129. isl_ctx *pet_expr_get_ctx(__isl_keep pet_expr *expr);
  130. /* Return the type of "expr". */
  131. enum pet_expr_type pet_expr_get_type(__isl_keep pet_expr *expr);
  132. /* Return the number of arguments of "expr". */
  133. int pet_expr_get_n_arg(__isl_keep pet_expr *expr);
  134. /* Set the number of arguments of "expr" to "n". */
  135. __isl_give pet_expr *pet_expr_set_n_arg(__isl_take pet_expr *expr, int n);
  136. /* Return the argument of "expr" at position "pos". */
  137. __isl_give pet_expr *pet_expr_get_arg(__isl_keep pet_expr *expr, int pos);
  138. /* Replace the argument of "expr" at position "pos" by "arg". */
  139. __isl_give pet_expr *pet_expr_set_arg(__isl_take pet_expr *expr, int pos,
  140. __isl_take pet_expr *arg);
  141. /* Return the operation type of operation expression "expr". */
  142. enum pet_op_type pet_expr_op_get_type(__isl_keep pet_expr *expr);
  143. /* Replace the operation type of operation expression "expr" by "type". */
  144. __isl_give pet_expr *pet_expr_op_set_type(__isl_take pet_expr *expr,
  145. enum pet_op_type type);
  146. /* Construct a (read) access pet_expr from an index expression. */
  147. __isl_give pet_expr *pet_expr_from_index(__isl_take isl_multi_pw_aff *index);
  148. /* Does "expr" represent an affine expression? */
  149. isl_bool pet_expr_is_affine(__isl_keep pet_expr *expr);
  150. /* Does the access expression "expr" read the accessed elements? */
  151. isl_bool pet_expr_access_is_read(__isl_keep pet_expr *expr);
  152. /* Does the access expression "expr" write to the accessed elements? */
  153. isl_bool pet_expr_access_is_write(__isl_keep pet_expr *expr);
  154. /* Does the access expression "expr" kill the accessed elements? */
  155. isl_bool pet_expr_access_is_kill(__isl_keep pet_expr *expr);
  156. /* Mark "expr" as a read depending on "read". */
  157. __isl_give pet_expr *pet_expr_access_set_read(__isl_take pet_expr *expr,
  158. int read);
  159. /* Mark "expr" as a write depending on "write". */
  160. __isl_give pet_expr *pet_expr_access_set_write(__isl_take pet_expr *expr,
  161. int write);
  162. /* Mark "expr" as a kill depending on "kill". */
  163. __isl_give pet_expr *pet_expr_access_set_kill(__isl_take pet_expr *expr,
  164. int kill);
  165. /* Return the reference identifier of access expression "expr". */
  166. __isl_give isl_id *pet_expr_access_get_ref_id(__isl_keep pet_expr *expr);
  167. /* Replace the reference identifier of access expression "expr" by "ref_id". */
  168. __isl_give pet_expr *pet_expr_access_set_ref_id(__isl_take pet_expr *expr,
  169. __isl_take isl_id *ref_id);
  170. /* Return the identifier of the outer array accessed by "expr". */
  171. __isl_give isl_id *pet_expr_access_get_id(__isl_keep pet_expr *expr);
  172. /* Return the index expression of access expression "expr". */
  173. __isl_give isl_multi_pw_aff *pet_expr_access_get_index(
  174. __isl_keep pet_expr *expr);
  175. /* Return the potential read access relation of access expression "expr". */
  176. __isl_give isl_union_map *pet_expr_access_get_may_read(
  177. __isl_keep pet_expr *expr);
  178. /* Return the potential write access relation of access expression "expr". */
  179. __isl_give isl_union_map *pet_expr_access_get_may_write(
  180. __isl_keep pet_expr *expr);
  181. /* Return the definite write access relation of access expression "expr". */
  182. __isl_give isl_union_map *pet_expr_access_get_must_write(
  183. __isl_keep pet_expr *expr);
  184. /* Return the argument dependent potential read access relation of "expr". */
  185. __isl_give isl_union_map *pet_expr_access_get_dependent_may_read(
  186. __isl_keep pet_expr *expr);
  187. /* Return the argument dependent potential write access relation of "expr". */
  188. __isl_give isl_union_map *pet_expr_access_get_dependent_may_write(
  189. __isl_keep pet_expr *expr);
  190. /* Return the argument dependent definite write access relation of "expr". */
  191. __isl_give isl_union_map *pet_expr_access_get_dependent_must_write(
  192. __isl_keep pet_expr *expr);
  193. /* Return the tagged potential read access relation of access "expr". */
  194. __isl_give isl_union_map *pet_expr_access_get_tagged_may_read(
  195. __isl_keep pet_expr *expr);
  196. /* Return the tagged potential write access relation of access "expr". */
  197. __isl_give isl_union_map *pet_expr_access_get_tagged_may_write(
  198. __isl_keep pet_expr *expr);
  199. /* Return the name of the function called by "expr". */
  200. __isl_keep const char *pet_expr_call_get_name(__isl_keep pet_expr *expr);
  201. /* Replace the name of the function called by "expr" by "name". */
  202. __isl_give pet_expr *pet_expr_call_set_name(__isl_take pet_expr *expr,
  203. __isl_keep const char *name);
  204. /* Create a pet_expr representing a cast of "arg" to "type_name". */
  205. __isl_give pet_expr *pet_expr_new_cast(const char *type_name,
  206. __isl_take pet_expr *arg);
  207. /* Replace the type of the cast performed by "expr" by "name". */
  208. __isl_give pet_expr *pet_expr_cast_set_type_name(__isl_take pet_expr *expr,
  209. __isl_keep const char *name);
  210. /* Return the value of the integer represented by "expr". */
  211. __isl_give isl_val *pet_expr_int_get_val(__isl_keep pet_expr *expr);
  212. /* Replace the value of the integer represented by "expr" by "v". */
  213. __isl_give pet_expr *pet_expr_int_set_val(__isl_take pet_expr *expr,
  214. __isl_take isl_val *v);
  215. /* Return a string representation of the double expression "expr". */
  216. __isl_give char *pet_expr_double_get_str(__isl_keep pet_expr *expr);
  217. /* Replace value and string representation of the double expression "expr" */
  218. __isl_give pet_expr *pet_expr_double_set(__isl_take pet_expr *expr,
  219. double d, __isl_keep const char *s);
  220. /* Call "fn" on each of the subexpressions of "expr" of type pet_expr_access. */
  221. int pet_expr_foreach_access_expr(__isl_keep pet_expr *expr,
  222. int (*fn)(__isl_keep pet_expr *expr, void *user), void *user);
  223. /* Call "fn" on each of the subexpressions of "expr" of type pet_expr_call. */
  224. int pet_expr_foreach_call_expr(__isl_keep pet_expr *expr,
  225. int (*fn)(__isl_keep pet_expr *expr, void *user), void *user);
  226. struct pet_context;
  227. typedef struct pet_context pet_context;
  228. /* Create a context with the given domain. */
  229. __isl_give pet_context *pet_context_alloc(__isl_take isl_set *domain);
  230. /* Return an additional reference to "pc". */
  231. __isl_give pet_context *pet_context_copy(__isl_keep pet_context *pc);
  232. /* Free a reference to "pc". */
  233. __isl_null pet_context *pet_context_free(__isl_take pet_context *pc);
  234. /* Return the isl_ctx in which "pc" was created. */
  235. isl_ctx *pet_context_get_ctx(__isl_keep pet_context *pc);
  236. /* Extract an affine expression defined over the domain of "pc" from "expr"
  237. * or return NaN.
  238. */
  239. __isl_give isl_pw_aff *pet_expr_extract_affine(__isl_keep pet_expr *expr,
  240. __isl_keep pet_context *pc);
  241. void pet_expr_dump(__isl_keep pet_expr *expr);
  242. enum pet_tree_type {
  243. pet_tree_error = -1,
  244. pet_tree_expr,
  245. pet_tree_block,
  246. pet_tree_break,
  247. pet_tree_continue,
  248. pet_tree_decl, /* A declaration without initialization */
  249. pet_tree_decl_init, /* A declaration with initialization */
  250. pet_tree_if, /* An if without an else branch */
  251. pet_tree_if_else, /* An if with an else branch */
  252. pet_tree_for,
  253. pet_tree_infinite_loop,
  254. pet_tree_while,
  255. pet_tree_return,
  256. };
  257. struct pet_tree;
  258. typedef struct pet_tree pet_tree;
  259. /* Return the isl_ctx in which "tree" was created. */
  260. isl_ctx *pet_tree_get_ctx(__isl_keep pet_tree *tree);
  261. /* Return an additional reference to "tree". */
  262. __isl_give pet_tree *pet_tree_copy(__isl_keep pet_tree *tree);
  263. /* Free a reference to "tree". */
  264. __isl_null pet_tree *pet_tree_free(__isl_take pet_tree *tree);
  265. /* Return the location of "tree". */
  266. __isl_give pet_loc *pet_tree_get_loc(__isl_keep pet_tree *tree);
  267. /* Return the type of "tree". */
  268. enum pet_tree_type pet_tree_get_type(__isl_keep pet_tree *tree);
  269. /* Return the expression of the expression tree "tree". */
  270. __isl_give pet_expr *pet_tree_expr_get_expr(__isl_keep pet_tree *tree);
  271. /* Return the expression returned by the return tree "tree". */
  272. __isl_give pet_expr *pet_tree_return_get_expr(__isl_keep pet_tree *tree);
  273. /* Return the number of children of the block tree "tree". */
  274. int pet_tree_block_n_child(__isl_keep pet_tree *tree);
  275. /* Return child "pos" of the block tree "tree". */
  276. __isl_give pet_tree *pet_tree_block_get_child(__isl_keep pet_tree *tree,
  277. int pos);
  278. /* Is "tree" a declaration (with or without initialization)? */
  279. int pet_tree_is_decl(__isl_keep pet_tree *tree);
  280. /* Return the variable declared by the declaration tree "tree". */
  281. __isl_give pet_expr *pet_tree_decl_get_var(__isl_keep pet_tree *tree);
  282. /* Return the initial value of the pet_tree_decl_init tree "tree". */
  283. __isl_give pet_expr *pet_tree_decl_get_init(__isl_keep pet_tree *tree);
  284. /* Return the condition of the if tree "tree". */
  285. __isl_give pet_expr *pet_tree_if_get_cond(__isl_keep pet_tree *tree);
  286. /* Return the then branch of the if tree "tree". */
  287. __isl_give pet_tree *pet_tree_if_get_then(__isl_keep pet_tree *tree);
  288. /* Return the else branch of the if tree with else branch "tree". */
  289. __isl_give pet_tree *pet_tree_if_get_else(__isl_keep pet_tree *tree);
  290. /* Is "tree" a for loop, a while loop or an infinite loop? */
  291. int pet_tree_is_loop(__isl_keep pet_tree *tree);
  292. /* Return the induction variable of the for loop "tree" */
  293. __isl_give pet_expr *pet_tree_loop_get_var(__isl_keep pet_tree *tree);
  294. /* Return the initial value of the induction variable of the for loop "tree" */
  295. __isl_give pet_expr *pet_tree_loop_get_init(__isl_keep pet_tree *tree);
  296. /* Return the condition of the loop tree "tree" */
  297. __isl_give pet_expr *pet_tree_loop_get_cond(__isl_keep pet_tree *tree);
  298. /* Return the induction variable of the for loop "tree" */
  299. __isl_give pet_expr *pet_tree_loop_get_inc(__isl_keep pet_tree *tree);
  300. /* Return the body of the loop tree "tree" */
  301. __isl_give pet_tree *pet_tree_loop_get_body(__isl_keep pet_tree *tree);
  302. /* Call "fn" on each top-level expression in the nodes of "tree" */
  303. int pet_tree_foreach_expr(__isl_keep pet_tree *tree,
  304. int (*fn)(__isl_keep pet_expr *expr, void *user), void *user);
  305. /* Call "fn" on each access subexpression in the nodes of "tree" */
  306. int pet_tree_foreach_access_expr(__isl_keep pet_tree *tree,
  307. int (*fn)(__isl_keep pet_expr *expr, void *user), void *user);
  308. /* Modify all call subexpressions in the nodes of "tree" through "fn". */
  309. __isl_give pet_tree *pet_tree_map_call_expr(__isl_take pet_tree *tree,
  310. __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
  311. void *user);
  312. void pet_tree_dump(__isl_keep pet_tree *tree);
  313. /* "loc" represents the region of the source code that is represented
  314. * by this statement.
  315. *
  316. * If the statement has arguments, i.e., n_arg != 0, then
  317. * "domain" is a wrapped map, mapping the iteration domain
  318. * to the values of the arguments for which this statement
  319. * is executed.
  320. * Otherwise, it is simply the iteration domain.
  321. *
  322. * If one of the arguments is an access expression that accesses
  323. * more than one element for a given iteration, then the constraints
  324. * on the value of this argument (encoded in "domain") should be satisfied
  325. * for all of those accessed elements.
  326. */
  327. struct pet_stmt {
  328. pet_loc *loc;
  329. isl_set *domain;
  330. pet_tree *body;
  331. unsigned n_arg;
  332. pet_expr **args;
  333. };
  334. /* Return the iteration space of "stmt". */
  335. __isl_give isl_space *pet_stmt_get_space(struct pet_stmt *stmt);
  336. /* Is "stmt" an assignment statement? */
  337. int pet_stmt_is_assign(struct pet_stmt *stmt);
  338. /* Is "stmt" a kill statement? */
  339. int pet_stmt_is_kill(struct pet_stmt *stmt);
  340. /* pet_stmt_build_ast_exprs is currently limited to only handle
  341. * some forms of data dependent accesses.
  342. * If pet_stmt_can_build_ast_exprs returns 1, then pet_stmt_build_ast_exprs
  343. * can safely be called on "stmt".
  344. */
  345. int pet_stmt_can_build_ast_exprs(struct pet_stmt *stmt);
  346. /* Construct an associative array from reference identifiers of
  347. * access expressions in "stmt" to the corresponding isl_ast_expr.
  348. * Each index expression is first transformed through "fn_index"
  349. * (if not NULL). Then an AST expression is generated using "build".
  350. * Finally, the AST expression is transformed using "fn_expr"
  351. * (if not NULL).
  352. */
  353. __isl_give isl_id_to_ast_expr *pet_stmt_build_ast_exprs(struct pet_stmt *stmt,
  354. __isl_keep isl_ast_build *build,
  355. __isl_give isl_multi_pw_aff *(*fn_index)(
  356. __isl_take isl_multi_pw_aff *mpa, __isl_keep isl_id *id,
  357. void *user), void *user_index,
  358. __isl_give isl_ast_expr *(*fn_expr)(__isl_take isl_ast_expr *expr,
  359. __isl_keep isl_id *id, void *user), void *user_expr);
  360. /* Print "stmt" to "p".
  361. *
  362. * The access expressions in "stmt" are replaced by the isl_ast_expr
  363. * associated to its reference identifier in "ref2expr".
  364. */
  365. __isl_give isl_printer *pet_stmt_print_body(struct pet_stmt *stmt,
  366. __isl_take isl_printer *p, __isl_keep isl_id_to_ast_expr *ref2expr);
  367. /* This structure represents a defined type.
  368. * "name" is the name of the type, while "definition" is a string
  369. * representation of its definition.
  370. */
  371. struct pet_type {
  372. char *name;
  373. char *definition;
  374. };
  375. /* context holds constraints on the parameter that ensure that
  376. * this array has a valid (i.e., non-negative) size
  377. *
  378. * extent holds constraints on the indices
  379. *
  380. * value_bounds holds constraints on the elements of the array
  381. * and may be NULL if no such constraints were specified by the user
  382. *
  383. * element_size is the size in bytes of each array element
  384. * element_type is the type of the array elements.
  385. * element_is_record is set if this type is a record type.
  386. *
  387. * live_out is set if the array appears in a live-out pragma
  388. *
  389. * if uniquely_defined is set then the array is written by a single access
  390. * such that any element that is ever read
  391. * is known to be assigned exactly once before the read
  392. *
  393. * declared is set if the array was declared somewhere inside the scop.
  394. * exposed is set if the declared array is visible outside the scop.
  395. * outer is set if the type of the array elements is a record and
  396. * the fields of this record are represented by separate pet_array structures.
  397. */
  398. struct pet_array {
  399. isl_set *context;
  400. isl_set *extent;
  401. isl_set *value_bounds;
  402. char *element_type;
  403. int element_is_record;
  404. int element_size;
  405. int live_out;
  406. int uniquely_defined;
  407. int declared;
  408. int exposed;
  409. int outer;
  410. };
  411. /* This structure represents an implication on a boolean filter.
  412. * In particular, if the filter value of an element in the domain
  413. * of "extension" is equal to "satisfied", then the filter values
  414. * of the corresponding images in "extension" are also equal
  415. * to "satisfied".
  416. */
  417. struct pet_implication {
  418. int satisfied;
  419. isl_map *extension;
  420. };
  421. /* This structure represents an independence implied by a for loop
  422. * that is marked as independent in the source code.
  423. * "filter" contains pairs of statement instances that are guaranteed
  424. * not to be dependent on each other based on the independent for loop,
  425. * assuming that no dependences carried by this loop are implied
  426. * by the variables in "local".
  427. * "local" contains the variables that are local to the loop that was
  428. * marked independent.
  429. */
  430. struct pet_independence {
  431. isl_union_map *filter;
  432. isl_union_set *local;
  433. };
  434. /* "loc" represents the region of the source code that is represented
  435. * by this scop.
  436. * If the scop was detected based on scop and endscop pragmas, then
  437. * the lines containing these pragmas are included in this region.
  438. * In the final result, the context describes the set of parameter values
  439. * for which the scop can be executed.
  440. * During the construction of the pet_scop, the context lives in a set space
  441. * where each dimension refers to an outer loop.
  442. * context_value describes assignments to the parameters (if any)
  443. * outside of the scop.
  444. *
  445. * "schedule" is the schedule of the statements in the scop.
  446. *
  447. * The n_type types define types that may be referenced from by the arrays.
  448. *
  449. * The n_implication implications describe implications on boolean filters.
  450. *
  451. * The n_independence independences describe independences implied
  452. * by for loops that are marked independent in the source code.
  453. */
  454. struct pet_scop {
  455. pet_loc *loc;
  456. isl_set *context;
  457. isl_set *context_value;
  458. isl_schedule *schedule;
  459. int n_type;
  460. struct pet_type **types;
  461. int n_array;
  462. struct pet_array **arrays;
  463. int n_stmt;
  464. struct pet_stmt **stmts;
  465. int n_implication;
  466. struct pet_implication **implications;
  467. int n_independence;
  468. struct pet_independence **independences;
  469. };
  470. typedef struct pet_scop pet_scop;
  471. /* Return a textual representation of the operator. */
  472. const char *pet_op_str(enum pet_op_type op);
  473. int pet_op_is_inc_dec(enum pet_op_type op);
  474. /* Extract a pet_scop from a C source file.
  475. * If function is not NULL, then the pet_scop is extracted from
  476. * a function with that name.
  477. */
  478. __isl_give pet_scop *pet_scop_extract_from_C_source(isl_ctx *ctx,
  479. const char *filename, const char *function);
  480. /* Transform the C source file "input" by rewriting each scop
  481. * When autodetecting scops, at most one scop per function is rewritten.
  482. * The transformed C code is written to "output".
  483. */
  484. int pet_transform_C_source(isl_ctx *ctx, const char *input, FILE *output,
  485. __isl_give isl_printer *(*transform)(__isl_take isl_printer *p,
  486. __isl_take pet_scop *scop, void *user), void *user);
  487. /* Given a scop and a printer passed to a pet_transform_C_source callback,
  488. * print the original corresponding code to the printer.
  489. */
  490. __isl_give isl_printer *pet_scop_print_original(__isl_keep pet_scop *scop,
  491. __isl_take isl_printer *p);
  492. /* Update all isl_sets and isl_maps such that they all have the same
  493. * parameters in the same order.
  494. */
  495. __isl_give pet_scop *pet_scop_align_params(__isl_take pet_scop *scop);
  496. /* Does "scop" contain any data dependent accesses? */
  497. int pet_scop_has_data_dependent_accesses(__isl_keep pet_scop *scop);
  498. /* Does "scop" contain any data dependent conditions? */
  499. int pet_scop_has_data_dependent_conditions(__isl_keep pet_scop *scop);
  500. /* pet_stmt_build_ast_exprs is currently limited to only handle
  501. * some forms of data dependent accesses.
  502. * If pet_scop_can_build_ast_exprs returns 1, then pet_stmt_build_ast_exprs
  503. * can safely be called on all statements in the scop.
  504. */
  505. int pet_scop_can_build_ast_exprs(__isl_keep pet_scop *scop);
  506. void pet_scop_dump(__isl_keep pet_scop *scop);
  507. __isl_null pet_scop *pet_scop_free(__isl_take pet_scop *scop);
  508. /* Return the context of "scop". */
  509. __isl_give isl_set *pet_scop_get_context(__isl_keep pet_scop *scop);
  510. /* Return the schedule of "scop". */
  511. __isl_give isl_schedule *pet_scop_get_schedule(__isl_keep pet_scop *scop);
  512. /* Return the set of all statement instances. */
  513. __isl_give isl_union_set *pet_scop_get_instance_set(__isl_keep pet_scop *scop);
  514. /* Return the potential read access relation. */
  515. __isl_give isl_union_map *pet_scop_get_may_reads(__isl_keep pet_scop *scop);
  516. /* Return the tagged potential read access relation. */
  517. __isl_give isl_union_map *pet_scop_get_tagged_may_reads(
  518. __isl_keep pet_scop *scop);
  519. /* Return the potential write access relation. */
  520. __isl_give isl_union_map *pet_scop_get_may_writes(__isl_keep pet_scop *scop);
  521. /* Return the definite write access relation. */
  522. __isl_give isl_union_map *pet_scop_get_must_writes(__isl_keep pet_scop *scop);
  523. /* Return the tagged potential write access relation. */
  524. __isl_give isl_union_map *pet_scop_get_tagged_may_writes(
  525. __isl_keep pet_scop *scop);
  526. /* Return the tagged definite write access relation. */
  527. __isl_give isl_union_map *pet_scop_get_tagged_must_writes(
  528. __isl_keep pet_scop *scop);
  529. /* Return the definite kill access relation. */
  530. __isl_give isl_union_map *pet_scop_get_must_kills(__isl_keep pet_scop *scop);
  531. /* Return the tagged definite kill access relation. */
  532. __isl_give isl_union_map *pet_scop_get_tagged_must_kills(
  533. __isl_keep pet_scop *scop);
  534. /* Compute a mapping from all outermost arrays (of structs) in scop
  535. * to their innermost members.
  536. */
  537. __isl_give isl_union_map *pet_scop_compute_outer_to_inner(
  538. __isl_keep pet_scop *scop);
  539. /* Compute a mapping from all outermost arrays (of structs) in scop
  540. * to their members, including the outermost arrays themselves.
  541. */
  542. __isl_give isl_union_map *pet_scop_compute_outer_to_any(
  543. __isl_keep pet_scop *scop);
  544. #if defined(__cplusplus)
  545. }
  546. #endif
  547. #endif