add exported isl_union_map_domain_reverse
authorSven Verdoolaege <sven@cerebras.net>
Tue, 19 Jul 2022 10:37:59 +0000 (19 12:37 +0200)
committerSven Verdoolaege <sven@cerebras.net>
Tue, 14 Feb 2023 21:49:17 +0000 (14 22:49 +0100)
This extends isl_map_domain_reverse to union maps.

Signed-off-by: Sven Verdoolaege <sven@cerebras.net>
doc/user.pod
include/isl/union_map.h
isl_test2.cc
isl_union_map.c

index 278c47b..51c0ed0 100644 (file)
@@ -5457,6 +5457,8 @@ earlier dimensions before those that involve later dimensions.
        #include <isl/union_map.h>
        __isl_give isl_union_map *isl_union_map_reverse(
                __isl_take isl_union_map *umap);
+       __isl_give isl_union_map *isl_union_map_domain_reverse(
+               __isl_take isl_union_map *umap);
        __isl_give isl_union_map *isl_union_map_range_reverse(
                __isl_take isl_union_map *umap);
 
index 182ba58..c17c27d 100644 (file)
@@ -227,6 +227,9 @@ __isl_give isl_union_map *isl_union_map_preimage_range_union_pw_multi_aff(
 __isl_export
 __isl_give isl_union_map *isl_union_map_reverse(__isl_take isl_union_map *umap);
 __isl_export
+__isl_give isl_union_map *isl_union_map_domain_reverse(
+       __isl_take isl_union_map *umap);
+__isl_export
 __isl_give isl_union_map *isl_union_map_range_reverse(
        __isl_take isl_union_map *umap);
 __isl_export
index d8bcf2b..fd1afd7 100644 (file)
@@ -513,6 +513,17 @@ static void test_reverse(isl::ctx ctx)
          "{ N[B[*] -> B[*]] -> A[] }" },
        });
 
+       C(&isl::union_map::domain_reverse, {
+       { "{ [A[] -> B[]] -> [C[] -> D[]] }",
+         "{ [B[] -> A[]] -> [C[] -> D[]] }" },
+       { "{ A[] -> [B[] -> C[]]; A[] -> B[]; A[0] -> N[B[1] -> B[2]] }",
+         "{ }" },
+       { "{ N[B[] -> C[]] -> A[] }",
+         "{ [C[] -> B[]] -> A[] }" },
+       { "{ N[B[x] -> B[y]] -> A[] }",
+         "{ N[B[*] -> B[*]] -> A[] }" },
+       });
+
        C(&isl::union_map::range_reverse, {
        { "{ A[] -> [B[] -> C[]]; A[] -> B[]; A[0] -> N[B[1] -> B[2]] }",
          "{ A[] -> [C[] -> B[]]; A[0] -> N[B[2] -> B[1]] }" },
index 12b4404..5a0f40e 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 Ecole Normale Superieure
  * Copyright 2014      INRIA Rocquencourt
  * Copyright 2016-2017 Sven Verdoolaege
+ * Copyright 2022      Cerebras Systems
  *
  * Use of this software is governed by the MIT license
  *
@@ -11,6 +12,7 @@
  * 91893 Orsay, France 
  * and Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt,
  * B.P. 105 - 78153 Le Chesnay, France
+ * and Cerebras Systems, 1237 E Arques Ave, Sunnyvale, CA, USA
  */
 
 #include <isl_map_private.h>
@@ -2317,6 +2319,21 @@ __isl_give isl_union_map *isl_union_map_reverse(__isl_take isl_union_map *umap)
        return un_op(umap, &control);
 }
 
+/* Given a union map, take the maps of the form (A -> B) -> C and
+ * return the union of the corresponding maps (B -> A) -> C.
+ */
+__isl_give isl_union_map *isl_union_map_domain_reverse(
+       __isl_take isl_union_map *umap)
+{
+       struct isl_un_op_drop_user_data data = { &isl_map_domain_is_wrapping };
+       struct isl_un_op_control control = {
+               .filter = &un_op_filter_drop_user,
+               .filter_user = &data,
+               .fn_map = &isl_map_domain_reverse,
+       };
+       return un_op(umap, &control);
+}
+
 /* Given a union map, take the maps of the form A -> (B -> C) and
  * return the union of the corresponding maps A -> (C -> B).
  */