X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_union_templ.c;h=65ab08fc8c4b7020d082209996ce92bf014279d3;hb=3d9f65131f9da197bca3a30eccf3a70107f50f03;hp=f6f46e24d883cb26894cc1bd249634ce3c8fd417;hpb=056289f285e62c52cc59ee826172e4d3092ef3fe;p=platform%2Fupstream%2Fisl.git diff --git a/isl_union_templ.c b/isl_union_templ.c index f6f46e2..65ab08f 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -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;