add exported isl_space_wrapped_reverse
authorSven Verdoolaege <sven@cerebras.net>
Thu, 24 Oct 2019 10:41:57 +0000 (24 12:41 +0200)
committerSven Verdoolaege <sven@cerebras.net>
Tue, 14 Feb 2023 21:31:45 +0000 (14 22:31 +0100)
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 <tianjiao.sun@cerebras.net>
Signed-off-by: Sven Verdoolaege <sven@cerebras.net>
doc/user.pod
include/isl/space.h
interface/template_cpp.cc
isl_space.c

index adabb3a..274a01a 100644 (file)
@@ -5418,6 +5418,8 @@ earlier dimensions before those that involve later dimensions.
        #include <isl/space.h>
        __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<isl_space_domain_reverse>.
+Along the same lines, C<isl_space_wrapped_reverse> reverses
+the relation that is embedded in a set space.
 
 =item * Tuple binding
 
index 1494b44..2c87a73 100644 (file)
@@ -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);
index 8643b55..de4762b 100644 (file)
@@ -614,6 +614,8 @@ static std::vector<Signature> 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 } },
 };
index 19808c5..83fd104 100644 (file)
@@ -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.
  *