X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_map_subtract.c;h=510937743a4ed4f7d349e54668b5ee9f809c5ffc;hb=ca69c58b8d1acc61cd71b7c51ee47803af4d902f;hp=59df4b162564bed2c369fd83d079b8d63ebb2e3b;hpb=f3c292bf31fbb13ce50a8877ee71910897276a24;p=platform%2Fupstream%2Fisl.git diff --git a/isl_map_subtract.c b/isl_map_subtract.c index 59df4b1..5109377 100644 --- a/isl_map_subtract.c +++ b/isl_map_subtract.c @@ -7,10 +7,10 @@ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */ +#include #include #include #include -#include "isl_map_private.h" #include "isl_tab.h" #include @@ -43,7 +43,7 @@ static int tab_add_constraints(struct isl_tab *tab, tab_total = isl_basic_map_total_dim(tab->bmap); bmap_total = isl_basic_map_total_dim(bmap); - dim = isl_dim_total(tab->bmap->dim); + dim = isl_space_dim(tab->bmap->dim, isl_dim_all); if (isl_tab_extend_cons(tab, 2 * bmap->n_eq + bmap->n_ineq) < 0) return -1; @@ -99,7 +99,7 @@ static int tab_add_constraint(struct isl_tab *tab, tab_total = isl_basic_map_total_dim(tab->bmap); bmap_total = isl_basic_map_total_dim(bmap); - dim = isl_dim_total(tab->bmap->dim); + dim = isl_space_dim(tab->bmap->dim, isl_dim_all); v = isl_vec_alloc(bmap->ctx, 1 + tab_total); if (!v) @@ -206,7 +206,8 @@ static int tab_freeze_constraints(struct isl_tab *tab) * Put the indices of the redundant constraints in index * and return the number of redundant constraints. */ -static int n_non_redundant(struct isl_tab *tab, int offset, int **index) +static int n_non_redundant(isl_ctx *ctx, struct isl_tab *tab, + int offset, int **index) { int i, n; int n_test = tab->n_con - offset; @@ -215,7 +216,7 @@ static int n_non_redundant(struct isl_tab *tab, int offset, int **index) return -1; if (!*index) - *index = isl_alloc_array(tab->mat->ctx, int, n_test); + *index = isl_alloc_array(ctx, int, n_test); if (!*index) return -1; @@ -248,7 +249,7 @@ struct isl_diff_collector { * a negative value is treated as an error, but the calling * function can interpret the results based on the state of dc. * - * Assumes that both bmap and map have known divs. + * Assumes that map has known divs. * * The difference is computed by a backtracking algorithm. * Each level corresponds to a basic map in "map". @@ -278,6 +279,7 @@ static int basic_map_collect_diff(__isl_take isl_basic_map *bmap, int level; int init; int empty; + isl_ctx *ctx; struct isl_tab *tab = NULL; struct isl_tab_undo **snap = NULL; int *k = NULL; @@ -298,6 +300,7 @@ static int basic_map_collect_diff(__isl_take isl_basic_map *bmap, if (!bmap || !map) goto error; + ctx = map->ctx; snap = isl_alloc_array(map->ctx, struct isl_tab_undo *, map->n); k = isl_alloc_array(map->ctx, int, map->n); n = isl_alloc_array(map->ctx, int, map->n); @@ -365,7 +368,8 @@ static int basic_map_collect_diff(__isl_take isl_basic_map *bmap, continue; } modified = 1; - n[level] = n_non_redundant(tab, offset, &index[level]); + n[level] = n_non_redundant(ctx, tab, offset, + &index[level]); if (n[level] < 0) goto error; if (n[level] == 0) { @@ -474,7 +478,8 @@ static __isl_give isl_map *basic_map_subtract(__isl_take isl_basic_map *bmap, /* Return the set difference between map1 and map2. * (U_i A_i) \ (U_j B_j) is computed as U_i (A_i \ (U_j B_j)) */ -struct isl_map *isl_map_subtract(struct isl_map *map1, struct isl_map *map2) +static __isl_give isl_map *map_subtract( __isl_take isl_map *map1, + __isl_take isl_map *map2) { int i; struct isl_map *diff; @@ -482,7 +487,7 @@ struct isl_map *isl_map_subtract(struct isl_map *map1, struct isl_map *map2) if (!map1 || !map2) goto error; - isl_assert(map1->ctx, isl_dim_equal(map1->dim, map2->dim), goto error); + isl_assert(map1->ctx, isl_space_is_equal(map1->dim, map2->dim), goto error); if (isl_map_is_empty(map2)) { isl_map_free(map2); @@ -518,6 +523,12 @@ error: return NULL; } +__isl_give isl_map *isl_map_subtract( __isl_take isl_map *map1, + __isl_take isl_map *map2) +{ + return isl_map_align_params_map_map_and(map1, map2, &map_subtract); +} + struct isl_set *isl_set_subtract(struct isl_set *set1, struct isl_set *set2) { return (struct isl_set *) @@ -556,7 +567,7 @@ static int basic_map_diff_is_empty(__isl_keep isl_basic_map *bmap, int r; struct isl_is_empty_diff_collector edc; - r = isl_basic_map_fast_is_empty(bmap); + r = isl_basic_map_plain_is_empty(bmap); if (r) return r; @@ -592,7 +603,7 @@ static int map_diff_is_empty(__isl_keep isl_map *map1, __isl_keep isl_map *map2) /* Return 1 if "bmap" contains a single element. */ -int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap) +int isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap) { if (!bmap) return -1; @@ -605,14 +616,14 @@ int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap) /* Return 1 if "map" contains a single element. */ -int isl_map_is_singleton(__isl_keep isl_map *map) +int isl_map_plain_is_singleton(__isl_keep isl_map *map) { if (!map) return -1; if (map->n != 1) return 0; - return isl_basic_map_is_singleton(map->p[0]); + return isl_basic_map_plain_is_singleton(map->p[0]); } /* Given a singleton basic map, extract the single element @@ -621,7 +632,7 @@ int isl_map_is_singleton(__isl_keep isl_map *map) static __isl_give isl_point *singleton_extract_point( __isl_keep isl_basic_map *bmap) { - int i, j; + int j; unsigned dim; struct isl_vec *point; isl_int m; @@ -639,7 +650,6 @@ static __isl_give isl_point *singleton_extract_point( isl_int_set_si(point->el[0], 1); for (j = 0; j < bmap->n_eq; ++j) { - int s; int i = dim - 1 - j; isl_assert(bmap->ctx, isl_seq_first_non_zero(bmap->eq[j] + 1, i) == -1, @@ -662,7 +672,7 @@ static __isl_give isl_point *singleton_extract_point( } isl_int_clear(m); - return isl_point_alloc(isl_basic_map_get_dim(bmap), point); + return isl_point_alloc(isl_basic_map_get_space(bmap), point); error: isl_int_clear(m); isl_vec_free(point); @@ -671,6 +681,7 @@ error: /* Return 1 is the singleton map "map1" is a subset of "map2", * i.e., if the single element of "map1" is also an element of "map2". + * Assumes "map2" has known divs. */ static int map_is_singleton_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2) @@ -701,30 +712,29 @@ static int map_is_singleton_subset(__isl_keep isl_map *map1, int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2) { int is_subset = 0; - struct isl_map *diff; if (!map1 || !map2) return -1; + if (!isl_map_has_equal_space(map1, map2)) + return 0; + if (isl_map_is_empty(map1)) return 1; if (isl_map_is_empty(map2)) return 0; - if (isl_map_fast_is_universe(map2)) + if (isl_map_plain_is_universe(map2)) return 1; - map1 = isl_map_compute_divs(isl_map_copy(map1)); map2 = isl_map_compute_divs(isl_map_copy(map2)); - if (isl_map_is_singleton(map1)) { + if (isl_map_plain_is_singleton(map1)) { is_subset = map_is_singleton_subset(map1, map2); - isl_map_free(map1); isl_map_free(map2); return is_subset; } is_subset = map_diff_is_empty(map1, map2); - isl_map_free(map1); isl_map_free(map2); return is_subset; @@ -784,7 +794,7 @@ __isl_give isl_set *isl_set_complement(__isl_take isl_set *set) if (!set) return NULL; - universe = isl_set_universe(isl_set_get_dim(set)); + universe = isl_set_universe(isl_set_get_space(set)); return isl_set_subtract(universe, set); }