X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_space.c;h=48f638558b54b1233a779482b6cebe6b6527251a;hb=ae50237b86f23c232dd5d99d3e420fa0e775ce01;hp=2b0920436e5aec287d5594f76154538f409ace0d;hpb=2d6726a1603607dfee8a3eacf357b91363fe2a30;p=platform%2Fupstream%2Fisl.git diff --git a/isl_space.c b/isl_space.c index 2b09204..48f6385 100644 --- a/isl_space.c +++ b/isl_space.c @@ -434,17 +434,37 @@ error: return NULL; } -__isl_give isl_space *isl_space_set_dim_id(__isl_take isl_space *dim, +/* Set the id of the given dimension of "space" to "id". + * If the dimension already has an id, then it is replaced. + * If the dimension is a parameter, then we need to change it + * in the nested spaces (if any) as well. + */ +__isl_give isl_space *isl_space_set_dim_id(__isl_take isl_space *space, enum isl_dim_type type, unsigned pos, __isl_take isl_id *id) { - dim = isl_space_cow(dim); - if (!dim || !id) + space = isl_space_cow(space); + if (!space || !id) goto error; - isl_id_free(get_id(dim, type, pos)); - return set_id(dim, type, pos, id); + + if (type == isl_dim_param) { + int i; + + for (i = 0; i < 2; ++i) { + if (!space->nested[i]) + continue; + space->nested[i] = + isl_space_set_dim_id(space->nested[i], + type, pos, isl_id_copy(id)); + if (!space->nested[i]) + goto error; + } + } + + isl_id_free(get_id(space, type, pos)); + return set_id(space, type, pos, id); error: isl_id_free(id); - isl_space_free(dim); + isl_space_free(space); return NULL; } @@ -543,6 +563,26 @@ int isl_space_find_dim_by_id(__isl_keep isl_space *dim, enum isl_dim_type type, return -1; } +int isl_space_find_dim_by_name(__isl_keep isl_space *space, + enum isl_dim_type type, const char *name) +{ + int i; + int offset; + int n; + + if (!space || !name) + return -1; + + offset = isl_space_offset(space, type); + n = isl_space_dim(space, type); + for (i = 0; i < n && offset + i < space->n_id; ++i) + if (space->ids[offset + i]->name && + !strcmp(space->ids[offset + i]->name, name)) + return i; + + return -1; +} + static __isl_keep isl_id *tuple_id(__isl_keep isl_space *dim, enum isl_dim_type type) { @@ -1047,6 +1087,24 @@ error: return NULL; } +__isl_give isl_space *isl_space_map_from_domain_and_range( + __isl_take isl_space *domain, __isl_take isl_space *range) +{ + if (!domain || !range) + goto error; + if (!isl_space_is_set(domain)) + isl_die(isl_space_get_ctx(domain), isl_error_invalid, + "domain is not a set space", goto error); + if (!isl_space_is_set(range)) + isl_die(isl_space_get_ctx(range), isl_error_invalid, + "range is not a set space", goto error); + return isl_space_join(isl_space_reverse(domain), range); +error: + isl_space_free(domain); + isl_space_free(range); + return NULL; +} + static __isl_give isl_space *set_ids(__isl_take isl_space *dim, enum isl_dim_type type, unsigned first, unsigned n, __isl_take isl_id **ids)