From: Sven Verdoolaege Date: Mon, 16 Feb 2009 14:47:30 +0000 (+0100) Subject: add isl_map_copy_basic_map and isl_map_drop_basic_map X-Git-Tag: isl-0.01~285 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eeaefb13e5ebb22a0fca021942825bd0d198e983;p=platform%2Fupstream%2Fisl.git add isl_map_copy_basic_map and isl_map_drop_basic_map --- diff --git a/include/isl_map.h b/include/isl_map.h index 9f8a588..9160a32 100644 --- a/include/isl_map.h +++ b/include/isl_map.h @@ -178,6 +178,10 @@ struct isl_map *isl_basic_map_lexmin( void isl_basic_map_dump(struct isl_basic_map *bmap, FILE *out, int indent); +struct isl_basic_map *isl_map_copy_basic_map(struct isl_map *map); +struct isl_map *isl_map_drop_basic_map(struct isl_map *map, + struct isl_basic_map *bmap); + int isl_basic_map_fast_is_fixed(struct isl_basic_map *bmap, enum isl_dim_type type, unsigned pos, isl_int *val); diff --git a/isl_map.c b/isl_map.c index 05b5b7e..839f2ed 100644 --- a/isl_map.c +++ b/isl_map.c @@ -3745,45 +3745,57 @@ struct isl_set *isl_set_remove_empty_parts(struct isl_set *set) isl_map_remove_empty_parts((struct isl_map *)set); } -struct isl_basic_set *isl_set_copy_basic_set(struct isl_set *set) +struct isl_basic_map *isl_map_copy_basic_map(struct isl_map *map) { - struct isl_basic_set *bset; - if (!set || set->n == 0) + struct isl_basic_map *bmap; + if (!map || map->n == 0) return NULL; - bset = set->p[set->n-1]; - isl_assert(set->ctx, F_ISSET(bset, ISL_BASIC_SET_FINAL), return NULL); - return isl_basic_set_copy(bset); + bmap = map->p[map->n-1]; + isl_assert(map->ctx, F_ISSET(bmap, ISL_BASIC_SET_FINAL), return NULL); + return isl_basic_map_copy(bmap); } -struct isl_set *isl_set_drop_basic_set(struct isl_set *set, - struct isl_basic_set *bset) +struct isl_basic_set *isl_set_copy_basic_set(struct isl_set *set) +{ + (struct isl_basic_set *)isl_map_copy_basic_map((struct isl_map *)set); +} + +struct isl_map *isl_map_drop_basic_map(struct isl_map *map, + struct isl_basic_map *bmap) { int i; - if (!set || !bset) + if (!map || !bmap) goto error; - for (i = set->n-1; i >= 0; --i) { - if (set->p[i] != bset) + for (i = map->n-1; i >= 0; --i) { + if (map->p[i] != bmap) continue; - set = isl_set_cow(set); - if (!set) + map = isl_map_cow(map); + if (!map) goto error; - isl_basic_set_free(set->p[i]); - if (i != set->n-1) { - F_CLR(set, ISL_SET_NORMALIZED); - set->p[i] = set->p[set->n-1]; + isl_basic_map_free(map->p[i]); + if (i != map->n-1) { + F_CLR(map, ISL_SET_NORMALIZED); + map->p[i] = map->p[map->n-1]; } - set->n--; - return set; + map->n--; + return map; } - isl_basic_set_free(bset); - return set; + isl_basic_map_free(bmap); + return map; error: - isl_set_free(set); - isl_basic_set_free(bset); + isl_map_free(map); + isl_basic_map_free(bmap); return NULL; } +struct isl_set *isl_set_drop_basic_set(struct isl_set *set, + struct isl_basic_set *bset) +{ + (struct isl_set *)isl_map_drop_basic_map((struct isl_map *)set, + (struct isl_basic_map *)bset); +} + /* Given two _disjoint_ basic sets bset1 and bset2, check whether * for any common value of the parameters and dimensions preceding dim * in both basic sets, the values of dimension pos in bset1 are