From d0836caae38e6cc6acdc9609920455b8aea5de88 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Tue, 4 Oct 2016 17:23:11 +0200 Subject: [PATCH] add isl_union_flow_copy This function allows union flow objects to be copied. This increases consistency with other isl objects, which commonly have isl_*_copy functions. Signed-off-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- doc/user.pod | 6 ++++-- include/isl/flow.h | 2 ++ isl_flow.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index b0877da2..262784bc 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -8739,8 +8739,8 @@ of type C can be obtained using C prints the information in flow format. -The output of C can be examined -and freed using the following functions. +The output of C can be examined, +copied, and freed using the following functions. #include __isl_give isl_union_map *isl_union_flow_get_must_dependence( @@ -8757,6 +8757,8 @@ and freed using the following functions. __isl_keep isl_union_flow *flow); __isl_give isl_union_map *isl_union_flow_get_may_no_source( __isl_keep isl_union_flow *flow); + __isl_give isl_union_flow *isl_union_flow_copy( + __isl_keep isl_union_flow *flow); __isl_null isl_union_flow *isl_union_flow_free( __isl_take isl_union_flow *flow); diff --git a/include/isl/flow.h b/include/isl/flow.h index 388d7919..a90c089e 100644 --- a/include/isl/flow.h +++ b/include/isl/flow.h @@ -107,6 +107,8 @@ __isl_give isl_union_flow *isl_union_access_info_compute_flow( __isl_take isl_union_access_info *access); isl_ctx *isl_union_flow_get_ctx(__isl_keep isl_union_flow *flow); +__isl_give isl_union_flow *isl_union_flow_copy( + __isl_keep isl_union_flow *flow); __isl_export __isl_give isl_union_map *isl_union_flow_get_must_dependence( __isl_keep isl_union_flow *flow); diff --git a/isl_flow.c b/isl_flow.c index b5ae691d..6e2a9a3a 100644 --- a/isl_flow.c +++ b/isl_flow.c @@ -1741,6 +1741,36 @@ error: return NULL; } +/* Copy this isl_union_flow object. + */ +__isl_give isl_union_flow *isl_union_flow_copy(__isl_keep isl_union_flow *flow) +{ + isl_union_flow *copy; + + if (!flow) + return NULL; + + copy = isl_union_flow_alloc(isl_union_map_get_space(flow->must_dep)); + + if (!copy) + return NULL; + + copy->must_dep = isl_union_map_union(copy->must_dep, + isl_union_map_copy(flow->must_dep)); + copy->may_dep = isl_union_map_union(copy->may_dep, + isl_union_map_copy(flow->may_dep)); + copy->must_no_source = isl_union_map_union(copy->must_no_source, + isl_union_map_copy(flow->must_no_source)); + copy->may_no_source = isl_union_map_union(copy->may_no_source, + isl_union_map_copy(flow->may_no_source)); + + if (!copy->must_dep || !copy->may_dep || + !copy->must_no_source || !copy->may_no_source) + return isl_union_flow_free(copy); + + return copy; +} + /* Drop the schedule dimensions from the iteration domains in "flow". * In particular, the schedule dimensions have been prepended * to the iteration domains prior to the dependence analysis by -- 2.11.4.GIT