From: Sven Verdoolaege Date: Sun, 15 Jul 2012 19:45:42 +0000 (+0200) Subject: add isl_multi_*_range_product X-Git-Tag: isl-0.11~141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a48f6c30bc4a2cb1410e4fe4c74ecabc098e051;p=platform%2Fupstream%2Fisl.git add isl_multi_*_range_product Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index afe122a..fe97e1b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -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); diff --git a/include/isl/aff.h b/include/isl/aff.h index 0132e6b..c47375d 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -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); diff --git a/isl_multi_templ.c b/isl_multi_templ.c index f9ccd08..520eb82 100644 --- a/isl_multi_templ.c +++ b/isl_multi_templ.c @@ -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; +}