add isl_schedule_foreach_band
[platform/upstream/isl.git] / isl_union_map.c
index 445d4fe..b1d0096 100644 (file)
@@ -936,6 +936,46 @@ __isl_give isl_union_map *isl_union_map_gist_domain(
        return gen_bin_op(umap, uset, &gist_domain_entry);
 }
 
+static int gist_range_entry(void **entry, void *user)
+{
+       struct isl_union_map_gen_bin_data *data = user;
+       uint32_t hash;
+       struct isl_hash_table_entry *entry2;
+       isl_space *space;
+       isl_map *map = *entry;
+       int empty;
+
+       space = isl_map_get_space(map);
+       space = isl_space_range(space);
+       hash = isl_space_get_hash(space);
+       entry2 = isl_hash_table_find(data->umap2->dim->ctx, &data->umap2->table,
+                                    hash, &has_dim, space, 0);
+       isl_space_free(space);
+       if (!entry2)
+               return 0;
+
+       map = isl_map_copy(map);
+       map = isl_map_gist_range(map, isl_set_copy(entry2->data));
+
+       empty = isl_map_is_empty(map);
+       if (empty < 0) {
+               isl_map_free(map);
+               return -1;
+       }
+
+       data->res = isl_union_map_add_map(data->res, map);
+
+       return 0;
+}
+
+/* Compute the gist of "umap" with respect to the range "uset".
+ */
+__isl_give isl_union_map *isl_union_map_gist_range(
+       __isl_take isl_union_map *umap, __isl_take isl_union_set *uset)
+{
+       return gen_bin_op(umap, uset, &gist_range_entry);
+}
+
 static int intersect_range_entry(void **entry, void *user)
 {
        struct isl_union_map_gen_bin_data *data = user;
@@ -1135,10 +1175,22 @@ __isl_give isl_union_map *isl_union_map_product(__isl_take isl_union_map *umap1,
        return bin_op(umap1, umap2, &product_entry);
 }
 
+static int set_product_entry(void **entry, void *user)
+{
+       struct isl_union_map_bin_data *data = user;
+       isl_set *set2 = *entry;
+
+       set2 = isl_set_product(isl_set_copy(data->map), isl_set_copy(set2));
+
+       data->res = isl_union_set_add_set(data->res, set2);
+
+       return 0;
+}
+
 __isl_give isl_union_set *isl_union_set_product(__isl_take isl_union_set *uset1,
        __isl_take isl_union_set *uset2)
 {
-       return isl_union_map_product(uset1, uset2);
+       return bin_op(uset1, uset2, &set_product_entry);
 }
 
 static int range_product_entry(void **entry, void *user)
@@ -1660,6 +1712,11 @@ static int is_subset_entry(void **entry, void *user)
        entry2 = isl_hash_table_find(data->umap2->dim->ctx, &data->umap2->table,
                                     hash, &has_dim, map->dim, 0);
        if (!entry2) {
+               int empty = isl_map_is_empty(map);
+               if (empty < 0)
+                       return -1;
+               if (empty)
+                       return 0;
                data->is_subset = 0;
                return -1;
        }
@@ -2192,6 +2249,27 @@ __isl_give isl_union_map *isl_union_map_zip(__isl_take isl_union_map *umap)
        return cond_un_op(umap, &zip_entry);
 }
 
+static int curry_entry(void **entry, void *user)
+{
+       isl_map *map = *entry;
+       isl_union_map **res = user;
+
+       if (!isl_map_can_curry(map))
+               return 0;
+
+       *res = isl_union_map_add_map(*res, isl_map_curry(isl_map_copy(map)));
+
+       return 0;
+}
+
+/* Given a union map, take the maps of the form (A -> B) -> C and
+ * return the union of the corresponding maps A -> (B -> C).
+ */
+__isl_give isl_union_map *isl_union_map_curry(__isl_take isl_union_map *umap)
+{
+       return cond_un_op(umap, &curry_entry);
+}
+
 static int lift_entry(void **entry, void *user)
 {
        isl_set *set = *entry;