From: Sven Verdoolaege Date: Sun, 17 Mar 2013 19:47:42 +0000 (+0100) Subject: isl_basic_map_project_out: extract out insert_div_rows X-Git-Tag: isl-0.12~181 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf586f0e0bc5d2ac4e7c3c50ed2178d483f25521;p=platform%2Fupstream%2Fisl.git isl_basic_map_project_out: extract out insert_div_rows The new insert_div_rows function will be reused in the next commit. Signed-off-by: Sven Verdoolaege --- diff --git a/isl_map.c b/isl_map.c index 47f3aa7..486e676 100644 --- a/isl_map.c +++ b/isl_map.c @@ -3366,31 +3366,22 @@ static __isl_give isl_basic_map *move_last(__isl_take isl_basic_map *bmap, return res; } -/* Turn the n dimensions of type type, starting at first - * into existentially quantified variables. +/* Insert "n" rows in the divs of "bmap". + * + * The number of columns is not changed, which means that the last + * dimensions of "bmap" are being reintepreted as the new divs. + * The space of "bmap" is not adjusted, however, which means + * that "bmap" is left in an inconsistent state. Removing "n" dimensions + * from the space of "bmap" is the responsibility of the caller. */ -__isl_give isl_basic_map *isl_basic_map_project_out( - __isl_take isl_basic_map *bmap, - enum isl_dim_type type, unsigned first, unsigned n) +static __isl_give isl_basic_map *insert_div_rows(__isl_take isl_basic_map *bmap, + int n) { int i; size_t row_size; isl_int **new_div; isl_int *old; - if (n == 0) - return basic_map_space_reset(bmap, type); - - if (!bmap) - return NULL; - - if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL)) - return isl_basic_map_remove_dims(bmap, type, first, n); - - isl_assert(bmap->ctx, first + n <= isl_basic_map_dim(bmap, type), - goto error); - - bmap = move_last(bmap, type, first, n); bmap = isl_basic_map_cow(bmap); if (!bmap) return NULL; @@ -3400,10 +3391,10 @@ __isl_give isl_basic_map *isl_basic_map_project_out( bmap->block2 = isl_blk_extend(bmap->ctx, bmap->block2, (bmap->extra + n) * (1 + row_size)); if (!bmap->block2.data) - goto error; + return isl_basic_map_free(bmap); new_div = isl_alloc_array(bmap->ctx, isl_int *, bmap->extra + n); if (!new_div) - goto error; + return isl_basic_map_free(bmap); for (i = 0; i < n; ++i) { new_div[i] = bmap->block2.data + (bmap->extra + i) * (1 + row_size); @@ -3416,6 +3407,34 @@ __isl_give isl_basic_map *isl_basic_map_project_out( bmap->n_div += n; bmap->extra += n; + return bmap; +} + +/* Turn the n dimensions of type type, starting at first + * into existentially quantified variables. + */ +__isl_give isl_basic_map *isl_basic_map_project_out( + __isl_take isl_basic_map *bmap, + enum isl_dim_type type, unsigned first, unsigned n) +{ + if (n == 0) + return basic_map_space_reset(bmap, type); + + if (!bmap) + return NULL; + + if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL)) + return isl_basic_map_remove_dims(bmap, type, first, n); + + isl_assert(bmap->ctx, first + n <= isl_basic_map_dim(bmap, type), + goto error); + + bmap = move_last(bmap, type, first, n); + bmap = isl_basic_map_cow(bmap); + bmap = insert_div_rows(bmap, n); + if (!bmap) + return NULL; + bmap->dim = isl_space_drop_dims(bmap->dim, type, first, n); if (!bmap->dim) goto error;