From 7c4cae5963249a00fc006fa342f206038394052d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 6 Jan 2014 13:40:52 +0100 Subject: [PATCH] Add isl_schedule_constraints_copy The wrapper generator in islpy depends on there being a "copy" method for (to first order) all types for which it writes wrappers, as "__isl_take" arguments are automatically copied on input. Signed-off-by: Andreas Kloeckner Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/schedule.h | 2 ++ isl_schedule.c | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index d8115a22..acaf0c23 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -5691,6 +5691,9 @@ and manipulated using the following functions. #include __isl_give isl_schedule_constraints * + isl_schedule_constraints_copy( + __isl_keep isl_schedule_constraints *sc); + __isl_give isl_schedule_constraints * isl_schedule_constraints_on_domain( __isl_take isl_union_set *domain); isl_ctx *isl_schedule_constraints_get_ctx( diff --git a/include/isl/schedule.h b/include/isl/schedule.h index 347bf9da..139a7e52 100644 --- a/include/isl/schedule.h +++ b/include/isl/schedule.h @@ -38,6 +38,8 @@ int isl_options_get_schedule_separate_components(isl_ctx *ctx); int isl_options_set_schedule_fuse(isl_ctx *ctx, int val); int isl_options_get_schedule_fuse(isl_ctx *ctx); +__isl_give isl_schedule_constraints *isl_schedule_constraints_copy( + __isl_keep isl_schedule_constraints *sc); __isl_give isl_schedule_constraints *isl_schedule_constraints_on_domain( __isl_take isl_union_set *domain); __isl_give isl_schedule_constraints *isl_schedule_constraints_set_validity( diff --git a/isl_schedule.c b/isl_schedule.c index 472c7f57..95555ad4 100644 --- a/isl_schedule.c +++ b/isl_schedule.c @@ -36,6 +36,32 @@ * Parallelization and Locality Optimization in the Polyhedral Model". */ + __isl_give isl_schedule_constraints *isl_schedule_constraints_copy( + __isl_keep isl_schedule_constraints *sc) +{ + isl_ctx *ctx; + isl_schedule_constraints *sc_copy; + enum isl_edge_type i; + + ctx = isl_union_set_get_ctx(sc->domain); + sc_copy = isl_calloc_type(ctx, struct isl_schedule_constraints); + if (!sc_copy) + return NULL; + + sc_copy->domain = isl_union_set_copy(sc->domain); + if (!sc_copy->domain) + return isl_schedule_constraints_free(sc_copy); + + for (i = isl_edge_first; i <= isl_edge_last; ++i) { + sc_copy->constraint[i] = isl_union_map_copy(sc->constraint[i]); + if (!sc_copy->constraint[i]) + return isl_schedule_constraints_free(sc_copy); + } + + return sc_copy; +} + + /* Construct an isl_schedule_constraints object for computing a schedule * on "domain". The initial object does not impose any constraints. */ -- 2.11.4.GIT