From 8f639103700247cc3d66ec3279e576a37670851a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 24 Oct 2019 12:41:57 +0200 Subject: [PATCH] add exported isl_space_wrapped_reverse This complements the functions isl_space_domain_reverse and isl_space_range_reverse. The name is derived from isl_space_reverse and matches the name of isl_set_wrapped_reverse, which will be introduced in an upcoming commit. Reviewed-by: Tianjiao Sun Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/space.h | 2 ++ interface/template_cpp.cc | 3 +++ isl_space.c | 17 +++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index adabb3a5..274a01a3 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -5418,6 +5418,8 @@ earlier dimensions before those that involve later dimensions. #include __isl_give isl_space *isl_space_reverse( __isl_take isl_space *space); + __isl_give isl_space *isl_space_wrapped_reverse( + __isl_take isl_space *space); __isl_give isl_space *isl_space_domain_reverse( __isl_take isl_space *space); __isl_give isl_space *isl_space_range_reverse( @@ -5442,6 +5444,8 @@ that is embedded in the range of the input map space. The identifier of the range, if any, is only preserved if this embedded relation has identical input and output tuples. Similarly for C. +Along the same lines, C reverses +the relation that is embedded in a set space. =item * Tuple binding diff --git a/include/isl/space.h b/include/isl/space.h index 1494b448..2c87a730 100644 --- a/include/isl/space.h +++ b/include/isl/space.h @@ -134,6 +134,8 @@ __isl_give isl_space *isl_space_map_from_domain_and_range( __isl_export __isl_give isl_space *isl_space_reverse(__isl_take isl_space *space); __isl_export +__isl_give isl_space *isl_space_wrapped_reverse(__isl_take isl_space *space); +__isl_export __isl_give isl_space *isl_space_domain_reverse(__isl_take isl_space *space); __isl_export __isl_give isl_space *isl_space_range_reverse(__isl_take isl_space *space); diff --git a/interface/template_cpp.cc b/interface/template_cpp.cc index 8643b55d..de4762b7 100644 --- a/interface/template_cpp.cc +++ b/interface/template_cpp.cc @@ -614,6 +614,8 @@ static std::vector fn_domain = { domain, set_params }; /* Signatures for interchanging (wrapped) domain and range. */ +static Signature set_reverse = + { { { Range, Domain } }, { { { Domain, Range } } } }; static Signature map_reverse = { { Range, Domain }, { { Domain, Range } } }; static Signature map_domain_reverse = { { { Domain2, Domain }, Range }, { { { Domain, Domain2 }, Range } } }; @@ -915,6 +917,7 @@ member_methods { { "unwrap", { unwrap } }, { "upper_bound", fn_bin_op }, { "wrap", { wrap } }, + { "wrapped_reverse", { set_reverse } }, { "zero", fn_un_op }, { "zero_on_domain", { anonymous_map_from_domain } }, }; diff --git a/isl_space.c b/isl_space.c index 19808c5f..83fd1044 100644 --- a/isl_space.c +++ b/isl_space.c @@ -2070,6 +2070,23 @@ __isl_give isl_space *isl_space_reverse_wrapped(__isl_take isl_space *space, return space; } +/* Given a space (A -> B), return the corresponding space + * (B -> A). + * + * If the domain tuple is named, then the name is only preserved + * if A and B are equal tuples, in which case the output + * of this function is identical to the input, except possibly + * for the dimension identifiers. + */ +__isl_give isl_space *isl_space_wrapped_reverse(__isl_take isl_space *space) +{ + if (isl_space_check_is_wrapping(space) < 0) + return isl_space_free(space); + space = isl_space_reverse_wrapped(space, isl_dim_set); + + return space; +} + /* Given a space (A -> B) -> C, return the corresponding space * (B -> A) -> C. * -- 2.11.4.GIT