add isl_multi_*_range_product
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 15 Jul 2012 19:45:42 +0000 (21:45 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Sep 2012 13:08:19 +0000 (15:08 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_multi_templ.c

index afe122a..fe97e1b 100644 (file)
@@ -3843,6 +3843,9 @@ Operations include
                __isl_take isl_pw_multi_aff *pma);
        __isl_give isl_union_set *isl_union_pw_multi_aff_domain(
                __isl_take isl_union_pw_multi_aff *upma);
+       __isl_give isl_multi_aff *isl_multi_aff_range_product(
+               __isl_take isl_multi_aff *ma1,
+               __isl_take isl_multi_aff *ma2);
        __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
                __isl_take isl_multi_aff *ma1,
                __isl_take isl_multi_aff *ma2);
@@ -3861,6 +3864,10 @@ Operations include
                __isl_take isl_union_pw_multi_aff *upma1,
                __isl_take isl_union_pw_multi_aff *upma2);
        __isl_give isl_multi_pw_aff *
+       isl_multi_pw_aff_range_product(
+               __isl_take isl_multi_pw_aff *mpa1,
+               __isl_take isl_multi_pw_aff *mpa2);
+       __isl_give isl_multi_pw_aff *
        isl_multi_pw_aff_flat_range_product(
                __isl_take isl_multi_pw_aff *mpa1,
                __isl_take isl_multi_pw_aff *mpa2);
index 0132e6b..c47375d 100644 (file)
@@ -303,6 +303,8 @@ __isl_give isl_multi_aff *isl_multi_aff_add(__isl_take isl_multi_aff *maff1,
 __isl_give isl_multi_aff *isl_multi_aff_scale(__isl_take isl_multi_aff *maff,
        isl_int f);
 
+__isl_give isl_multi_aff *isl_multi_aff_range_product(
+       __isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2);
 __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
        __isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2);
 __isl_give isl_multi_aff *isl_multi_aff_product(
@@ -512,6 +514,8 @@ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_set_dim_name(
 
 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_flat_range_product(
        __isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_range_product(
+       __isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2);
 
 __isl_give isl_printer *isl_printer_print_multi_pw_aff(
        __isl_take isl_printer *p, __isl_keep isl_multi_pw_aff *mpa);
index f9ccd08..520eb82 100644 (file)
@@ -616,7 +616,7 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),drop_dims)(
 /* Given two MULTI(BASE)s A -> B and C -> D,
  * construct a MULTI(BASE) (A * C) -> (B, D).
  */
-__isl_give MULTI(BASE) *FN(MULTI(BASE),flat_range_product)(
+__isl_give MULTI(BASE) *FN(MULTI(BASE),range_product)(
        __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
 {
        int i, n1, n2;
@@ -629,7 +629,6 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),flat_range_product)(
 
        space = isl_space_range_product(FN(MULTI(BASE),get_space)(multi1),
                                        FN(MULTI(BASE),get_space)(multi2));
-       space = isl_space_flatten_range(space);
        res = FN(MULTI(BASE),alloc)(space);
 
        n1 = FN(MULTI(BASE),dim)(multi1, isl_dim_out);
@@ -653,3 +652,36 @@ error:
        FN(MULTI(BASE),free)(multi2);
        return NULL;
 }
+
+__isl_give MULTI(BASE) *FN(MULTI(BASE),flatten_range)(
+       __isl_take MULTI(BASE) *multi)
+{
+       if (!multi)
+               return NULL;
+
+       if (!multi->space->nested[1])
+               return multi;
+
+       multi = FN(MULTI(BASE),cow)(multi);
+       if (!multi)
+               return NULL;
+
+       multi->space = isl_space_flatten_range(multi->space);
+       if (!multi->space)
+               return FN(MULTI(BASE),free)(multi);
+
+       return multi;
+}
+
+/* Given two MULTI(BASE)s A -> B and C -> D,
+ * construct a MULTI(BASE) (A * C) -> [B -> D].
+ */
+__isl_give MULTI(BASE) *FN(MULTI(BASE),flat_range_product)(
+       __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
+{
+       MULTI(BASE) *multi;
+
+       multi = FN(MULTI(BASE),range_product)(multi1, multi2);
+       multi = FN(MULTI(BASE),flatten_range)(multi);
+       return multi;
+}