X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_pw_templ.c;h=da4b53e5ec2a13445b4b7bb170a66f18ca7775e9;hb=78b3cfae0a9cad8fbca88a9b5ce79337c2ba01c3;hp=0555091ac2c6422820ded59fcd99b20c94466a3f;hpb=661c3743a58bd69d5c7e5d62a716c0f2cd857e65;p=platform%2Fupstream%2Fisl.git diff --git a/isl_pw_templ.c b/isl_pw_templ.c index 0555091..da4b53e 100644 --- a/isl_pw_templ.c +++ b/isl_pw_templ.c @@ -918,3 +918,42 @@ error: FN(PW,free)(pw); return NULL; } + +__isl_give PW *FN(PW,mul_isl_int)(__isl_take PW *pw, isl_int v) +{ + int i; + + if (isl_int_is_one(v)) + return pw; + if (pw && isl_int_is_zero(v)) { + PW *zero; + isl_dim *dim = FN(PW,get_dim)(pw); +#ifdef HAS_TYPE + zero = FN(PW,zero)(dim, pw->type); +#else + zero = FN(PW,zero)(dim); +#endif + FN(PW,free)(pw); + return zero; + } + pw = FN(PW,cow)(pw); + if (!pw) + return NULL; + if (pw->n == 0) + return pw; + +#ifdef HAS_TYPE + if (isl_int_is_neg(v)) + pw->type = isl_fold_type_negate(pw->type); +#endif + for (i = 0; i < pw->n; ++i) { + pw->p[i].FIELD = FN(EL,mul_isl_int)(pw->p[i].FIELD, v); + if (!pw->p[i].FIELD) + goto error; + } + + return pw; +error: + FN(PW,free)(pw); + return NULL; +}