From: Sven Verdoolaege Date: Mon, 22 Sep 2008 14:44:30 +0000 (+0200) Subject: add isl_set_copy_basic_set and isl_set_drop_basic_set X-Git-Tag: isl-0.01~393 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f6a6faa1fec95c945016097503f796b54860ed1;p=platform%2Fupstream%2Fisl.git add isl_set_copy_basic_set and isl_set_drop_basic_set --- diff --git a/include/isl_set.h b/include/isl_set.h index 37627b0..ea15558 100644 --- a/include/isl_set.h +++ b/include/isl_set.h @@ -140,6 +140,10 @@ int isl_set_is_equal(struct isl_set *set1, struct isl_set *set2); struct isl_set *isl_basic_set_compute_divs(struct isl_basic_set *bset); +struct isl_basic_set *isl_set_copy_basic_set(struct isl_set *set); +struct isl_set *isl_set_drop_basic_set(struct isl_set *set, + struct isl_basic_set *bset); + #if defined(__cplusplus) } #endif diff --git a/isl_map.c b/isl_map.c index 54eb8ed..7652207 100644 --- a/isl_map.c +++ b/isl_map.c @@ -1426,8 +1426,8 @@ void isl_basic_set_dump(struct isl_basic_set *bset, FILE *out, int indent) } fprintf(out, "%*s", indent, ""); - fprintf(out, "nparam: %d, dim: %d, extra: %d\n", - bset->nparam, bset->dim, bset->extra); + fprintf(out, "ref: %d, nparam: %d, dim: %d, extra: %d\n", + bset->ref, bset->nparam, bset->dim, bset->extra); dump((struct isl_basic_map *)bset, out, indent); } @@ -3540,3 +3540,40 @@ struct isl_set *isl_set_remove_empty_parts(struct isl_set *set) return (struct isl_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_set *bset; + if (!set || set->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); +} + +struct isl_set *isl_set_drop_basic_set(struct isl_set *set, + struct isl_basic_set *bset) +{ + int i; + + if (!set || !bset) + goto error; + for (i = set->n-1; i >= 0; --i) { + if (set->p[i] != bset) + continue; + set = isl_set_cow(set); + if (!set) + goto error; + isl_basic_set_free(set->p[i]); + if (i != set->n-1) + set->p[i] = set->p[set->n-1]; + set->n--; + return set; + } + isl_basic_set_free(bset); + return set; +error: + isl_set_free(set); + isl_basic_set_free(bset); + return NULL; +}