ppcg.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef PPCG_H
  2. #define PPCG_H
  3. #include <isl/schedule.h>
  4. #include <isl/set.h>
  5. #include <isl/union_set.h>
  6. #include <isl/union_map.h>
  7. #include <isl/id_to_ast_expr.h>
  8. #include <pet.h>
  9. #include "ppcg_options.h"
  10. const char *ppcg_base_name(const char *filename);
  11. int ppcg_extract_base_name(char *name, const char *input);
  12. /* Representation of the scop for use inside PPCG.
  13. *
  14. * "options" are the options specified by the user.
  15. * Some fields in this structure may depend on some of the options.
  16. *
  17. * "start" and "end" are file offsets of the corresponding program text.
  18. * "context" represents constraints on the parameters.
  19. * "domain" is the union of all iteration domains.
  20. * "call" contains the iteration domains of statements with a call expression.
  21. * "reads" contains all potential read accesses.
  22. * "tagged_reads" is the same as "reads", except that the domain is a wrapped
  23. * relation mapping an iteration domain to a reference identifier
  24. * "live_in" contains the potential read accesses that potentially
  25. * have no corresponding writes in the scop.
  26. * "may_writes" contains all potential write accesses.
  27. * "tagged_may_writes" is the same as "may_writes", except that the domain
  28. * is a wrapped relation mapping an iteration domain
  29. * to a reference identifier
  30. * "must_writes" contains all definite write accesses.
  31. * "tagged_must_writes" is the same as "must_writes", except that the domain
  32. * is a wrapped relation mapping an iteration domain
  33. * to a reference identifier
  34. * "live_out" contains the potential write accesses that are potentially
  35. * not killed by any kills or any other writes.
  36. * "must_kills" contains all definite kill accesses.
  37. * "tagged_must_kills" is the same as "must_kills", except that the domain
  38. * is a wrapped relation mapping an iteration domain
  39. * to a reference identifier.
  40. *
  41. * "tagger" maps tagged iteration domains to the corresponding untagged
  42. * iteration domain.
  43. *
  44. * "independence" is the union of all independence filters.
  45. *
  46. * "dep_flow" represents the potential flow dependences.
  47. * "tagged_dep_flow" is the same as "dep_flow", except that both domain and
  48. * range are wrapped relations mapping an iteration domain to
  49. * a reference identifier. May be NULL if not computed.
  50. * "dep_false" represents the potential false (anti and output) dependences.
  51. * "dep_forced" represents the validity constraints that should be enforced
  52. * even when live-range reordering is used.
  53. * In particular, these constraints ensure that all live-in
  54. * accesses remain live-in and that all live-out accesses remain live-out
  55. * and that multiple potential sources for the same read are
  56. * executed in the original order.
  57. * "dep_order"/"tagged_dep_order" represents the order dependences between
  58. * the live range intervals in "dep_flow"/"tagged_dep_flow".
  59. * It is only used if the live_range_reordering
  60. * option is set. Otherwise it is NULL.
  61. * If "dep_order" is used, then "dep_false" only contains a limited
  62. * set of anti and output dependences.
  63. * "schedule" represents the (original) schedule.
  64. *
  65. * "names" contains all variable names that are in use by the scop.
  66. * The names are mapped to a dummy value.
  67. *
  68. * "pet" is the original pet_scop.
  69. */
  70. struct ppcg_scop {
  71. struct ppcg_options *options;
  72. unsigned start;
  73. unsigned end;
  74. isl_set *context;
  75. isl_union_set *domain;
  76. isl_union_set *call;
  77. isl_union_map *tagged_reads;
  78. isl_union_map *reads;
  79. isl_union_map *live_in;
  80. isl_union_map *tagged_may_writes;
  81. isl_union_map *may_writes;
  82. isl_union_map *tagged_must_writes;
  83. isl_union_map *must_writes;
  84. isl_union_map *live_out;
  85. isl_union_map *tagged_must_kills;
  86. isl_union_map *must_kills;
  87. isl_union_pw_multi_aff *tagger;
  88. isl_union_map *independence;
  89. isl_union_map *dep_flow;
  90. isl_union_map *tagged_dep_flow;
  91. isl_union_map *dep_false;
  92. isl_union_map *dep_forced;
  93. isl_union_map *dep_order;
  94. isl_union_map *tagged_dep_order;
  95. isl_schedule *schedule;
  96. isl_id_to_ast_expr *names;
  97. struct pet_scop *pet;
  98. };
  99. int ppcg_scop_any_hidden_declarations(struct ppcg_scop *scop);
  100. __isl_give isl_id_list *ppcg_scop_generate_names(struct ppcg_scop *scop,
  101. int n, const char *prefix);
  102. int ppcg_transform(isl_ctx *ctx, const char *input, FILE *out,
  103. struct ppcg_options *options,
  104. __isl_give isl_printer *(*fn)(__isl_take isl_printer *p,
  105. struct ppcg_scop *scop, void *user), void *user);
  106. __isl_give isl_schedule *ppcg_compute_schedule(
  107. __isl_take isl_schedule_constraints *sc,
  108. __isl_keep isl_schedule *schedule, struct ppcg_options *options);
  109. void compute_tagger(struct ppcg_scop *ps);
  110. void compute_dependences(struct ppcg_scop *scop);
  111. void eliminate_dead_code(struct ppcg_scop *ps);
  112. void *ppcg_scop_free(struct ppcg_scop *ps);
  113. #endif