From bebd4175ed72b6c1c633cd163f98989ab98be3fa Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 9 May 2017 18:41:17 +0200 Subject: [PATCH] add isl_union_map_intersect_range_factor_range This function will be used in the next commit. Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/union_map.h | 2 ++ isl_union_map.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 82cbd352..9e1db4f9 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -5876,6 +5876,10 @@ the same (number of) parameters. __isl_give isl_union_map *isl_union_map_intersect( __isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2); + __isl_give isl_union_map * + isl_union_map_intersect_range_factor_range( + __isl_take isl_union_map *umap, + __isl_take isl_union_map *factor); #include __isl_give isl_pw_aff *isl_pw_aff_intersect_domain( diff --git a/include/isl/union_map.h b/include/isl/union_map.h index fa2310ec..a3efe6f4 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -145,6 +145,8 @@ __isl_give isl_union_map *isl_union_map_intersect_domain( __isl_export __isl_give isl_union_map *isl_union_map_intersect_range( __isl_take isl_union_map *umap, __isl_take isl_union_set *uset); +__isl_give isl_union_map *isl_union_map_intersect_range_factor_range( + __isl_take isl_union_map *umap, __isl_take isl_union_map *factor); __isl_export __isl_give isl_union_map *isl_union_map_subtract_domain( diff --git a/isl_union_map.c b/isl_union_map.c index 5dbc4aa0..a5ae1354 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -614,6 +614,10 @@ isl_stat isl_union_set_foreach_point(__isl_keep isl_union_set *uset, * if there is no corresponding map in the second input. * Otherwise, a map in the first input with no corresponding map * in the second input is ignored. + * If "filter" is not NULL, then it specifies which maps in the first + * input may have a matching map in the second input. + * In particular, it makes sure that "match_space" can be called + * on the space of the map. * "match_space" specifies how to transform the space of a map * in the first input to the space of the corresponding map * in the second input. @@ -622,6 +626,7 @@ isl_stat isl_union_set_foreach_point(__isl_keep isl_union_set *uset, */ struct isl_bin_op_control { int subtract; + isl_bool (*filter)(__isl_keep isl_map *map); __isl_give isl_space *(*match_space)(__isl_take isl_space *space); __isl_give isl_map *(*fn_map)(__isl_take isl_map *map1, __isl_take isl_map *map2); @@ -679,6 +684,8 @@ static __isl_give isl_space *identity(__isl_take isl_space *space) * (isl_bool_false, NULL) if there is no matching map and * (isl_bool_error, NULL) on error. * + * If not NULL, then data->control->filter specifies whether "map" + * can have any matching map. If so, * data->control->match_space specifies which map in data->umap2 * corresponds to "map". */ @@ -690,6 +697,13 @@ static __isl_keep isl_maybe_isl_map bin_try_get_match( isl_space *space; isl_maybe_isl_map res = { isl_bool_error, NULL }; + if (data->control->filter) { + res.valid = data->control->filter(map); + if (res.valid < 0 || !res.valid) + return res; + res.valid = isl_bool_error; + } + space = isl_map_get_space(map); if (data->control->match_space != &identity) space = data->control->match_space(space); @@ -1202,6 +1216,22 @@ __isl_give isl_union_map *isl_union_map_intersect_range( return gen_bin_op(umap, uset, &control); } +/* Intersect each map in "umap" in a space A -> [B -> C] + * with the corresponding map in "factor" in the space A -> C and + * collect the results. + */ +__isl_give isl_union_map *isl_union_map_intersect_range_factor_range( + __isl_take isl_union_map *umap, __isl_take isl_union_map *factor) +{ + struct isl_bin_op_control control = { + .filter = &isl_map_range_is_wrapping, + .match_space = &isl_space_range_factor_range, + .fn_map = &isl_map_intersect_range_factor_range, + }; + + return gen_bin_op(umap, factor, &control); +} + struct isl_union_map_bin_data { isl_union_map *umap2; isl_union_map *res; -- 2.11.4.GIT