From 9fd483e3952c40b4060bad017787d55c59025a96 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 6 Jan 2014 18:10:13 +0100 Subject: [PATCH] add isl_schedule_insert_partial_schedule Signed-off-by: Sven Verdoolaege --- doc/user.pod | 9 +++++++++ include/isl/schedule.h | 5 +++++ isl_schedule.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 6738dd3d..c9031286 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -7300,6 +7300,15 @@ can be obtained using the following function. __isl_give isl_union_set *isl_schedule_get_domain( __isl_keep isl_schedule *schedule); +An extra top-level band node (right underneath the domain node) can +be introduced into the schedule using the following function. + + #include + __isl_give isl_schedule * + isl_schedule_insert_partial_schedule( + __isl_take isl_schedule *schedule, + __isl_take isl_multi_union_pw_aff *partial); + An C representation of the schedule can be obtained from an C using the following function. diff --git a/include/isl/schedule.h b/include/isl/schedule.h index 402afa35..86cbc6c0 100644 --- a/include/isl/schedule.h +++ b/include/isl/schedule.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,10 @@ __isl_give isl_schedule *isl_schedule_map_schedule_node( __isl_give isl_schedule_node *(*fn)( __isl_take isl_schedule_node *node, void *user), void *user); +__isl_give isl_schedule *isl_schedule_insert_partial_schedule( + __isl_take isl_schedule *schedule, + __isl_take isl_multi_union_pw_aff *partial); + __isl_give isl_band_list *isl_schedule_get_band_forest( __isl_keep isl_schedule *schedule); diff --git a/isl_schedule.c b/isl_schedule.c index 14623f75..8eae0d18 100644 --- a/isl_schedule.c +++ b/isl_schedule.c @@ -751,6 +751,37 @@ static __isl_give isl_printer *print_band_list(__isl_take isl_printer *p, return p; } +/* Insert a band node with partial schedule "partial" between the domain + * root node of "schedule" and its single child. + * Return a pointer to the updated schedule. + */ +__isl_give isl_schedule *isl_schedule_insert_partial_schedule( + __isl_take isl_schedule *schedule, + __isl_take isl_multi_union_pw_aff *partial) +{ + isl_schedule_node *node; + + node = isl_schedule_get_root(schedule); + isl_schedule_free(schedule); + if (!node) + goto error; + if (isl_schedule_node_get_type(node) != isl_schedule_node_domain) + isl_die(isl_schedule_node_get_ctx(node), isl_error_internal, + "root node not a domain node", goto error); + + node = isl_schedule_node_child(node, 0); + node = isl_schedule_node_insert_partial_schedule(node, partial); + + schedule = isl_schedule_node_get_schedule(node); + isl_schedule_node_free(node); + + return schedule; +error: + isl_schedule_node_free(node); + isl_multi_union_pw_aff_free(partial); + return NULL; +} + /* Print "schedule" to "p". * * If "schedule" was created from a schedule tree, then we print -- 2.11.4.GIT