X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_union_templ.c;h=65ab08fc8c4b7020d082209996ce92bf014279d3;hb=refs%2Fheads%2Ftizen_3.0.m1_mobile;hp=e182f726eb71e162d8b4335d523bcdf7c1317764;hpb=0ef948d8459c74b96856a6d6c3bae9719f25ba9e;p=platform%2Fupstream%2Fisl.git diff --git a/isl_union_templ.c b/isl_union_templ.c index e182f72..65ab08f 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -1,7 +1,7 @@ /* * Copyright 2010 INRIA Saclay * - * Use of this software is governed by the GNU LGPLv2.1 license + * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, @@ -465,6 +465,15 @@ error: return NULL; } +#ifndef NO_SUB +/* Subtract "u2" from "u1" and return the result. + */ +__isl_give UNION *FN(UNION,sub)(__isl_take UNION *u1, __isl_take UNION *u2) +{ + return match_bin_op(u1, u2, &FN(PART,sub)); +} +#endif + S(UNION,any_set_data) { isl_set *set; UNION *res; @@ -796,6 +805,70 @@ error: return NULL; } +/* Multiply *entry by the isl_val "user". + * + * Return 0 on success and -1 on error. + */ +static int scale_val(void **entry, void *user) +{ + PW **pw = (PW **)entry; + isl_val *v = user; + + *pw = FN(PW,scale_val)(*pw, isl_val_copy(v)); + if (!*pw) + return -1; + + return 0; +} + +/* Multiply "u" by "v" and return the result. + */ +__isl_give UNION *FN(UNION,scale_val)(__isl_take UNION *u, + __isl_take isl_val *v) +{ + if (!u || !v) + goto error; + if (isl_val_is_one(v)) { + isl_val_free(v); + return u; + } + + if (DEFAULT_IS_ZERO && u && isl_val_is_zero(v)) { + UNION *zero; + isl_space *space = FN(UNION,get_space)(u); +#ifdef HAS_TYPE + zero = FN(UNION,ZERO)(space, u->type); +#else + zero = FN(UNION,ZERO)(space); +#endif + FN(UNION,free)(u); + isl_val_free(v); + return zero; + } + + if (!isl_val_is_rat(v)) + isl_die(isl_val_get_ctx(v), isl_error_invalid, + "expecting rational factor", goto error); + + u = FN(UNION,cow)(u); + if (!u) + return NULL; + +#ifdef HAS_TYPE + if (isl_val_is_neg(v)) + u->type = isl_fold_type_negate(u->type); +#endif + if (isl_hash_table_foreach(u->dim->ctx, &u->table, &scale_val, v) < 0) + goto error; + + isl_val_free(v); + return u; +error: + isl_val_free(v); + FN(UNION,free)(u); + return NULL; +} + S(UNION,plain_is_equal_data) { UNION *u2;