isl_set_get_simple_fixed_box_hull: extract out fixed_box_as_map
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Wed, 21 Jul 2021 10:20:22 +0000 (21 12:20 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Mon, 26 Jul 2021 19:35:41 +0000 (26 21:35 +0200)
This will be reused in the next commit.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_box.c

index d4eb54f..1e7260c 100644 (file)
--- a/isl_box.c
+++ b/isl_box.c
@@ -409,6 +409,24 @@ __isl_give isl_fixed_box *isl_map_get_range_simple_fixed_box_hull(
        return box;
 }
 
+/* Compute a fixed box from "set" using "map_box" by treating it as a map
+ * with a zero-dimensional domain and
+ * project out the domain again from the result.
+ */
+static __isl_give isl_fixed_box *fixed_box_as_map(__isl_keep isl_set *set,
+       __isl_give isl_fixed_box *(*map_box)(__isl_keep isl_map *map))
+{
+       isl_map *map;
+       isl_fixed_box *box;
+
+       map = isl_map_from_range(isl_set_copy(set));
+       box = map_box(map);
+       isl_map_free(map);
+       box = isl_fixed_box_project_domain_on_params(box);
+
+       return box;
+}
+
 /* Try and construct a fixed-size rectangular box with an offset
  * in terms of the parameters of "set" that contains "set".
  * If no such box can be constructed, then return an invalidated box,
@@ -421,15 +439,7 @@ __isl_give isl_fixed_box *isl_map_get_range_simple_fixed_box_hull(
 __isl_give isl_fixed_box *isl_set_get_simple_fixed_box_hull(
        __isl_keep isl_set *set)
 {
-       isl_map *map;
-       isl_fixed_box *box;
-
-       map = isl_map_from_range(isl_set_copy(set));
-       box = isl_map_get_range_simple_fixed_box_hull(map);
-       isl_map_free(map);
-       box = isl_fixed_box_project_domain_on_params(box);
-
-       return box;
+       return fixed_box_as_map(set, &isl_map_get_range_simple_fixed_box_hull);
 }
 
 /* Check whether the output elements lie on a rectangular lattice,