From 3a67f114ea043c4c8957843ad4dab9e34179d85c Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 27 Jun 2013 17:10:48 +0200 Subject: [PATCH] add isl_multi_aff_domain_map Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/aff.h | 1 + isl_aff.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index cc27bc5a..5aef59ba 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3977,6 +3977,8 @@ can be created using the following functions. __isl_take isl_space *space); __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity( __isl_take isl_space *space); + __isl_give isl_multi_aff *isl_multi_aff_domain_map( + __isl_take isl_space *space); __isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_multi_aff( __isl_take isl_multi_aff *ma); diff --git a/include/isl/aff.h b/include/isl/aff.h index 4ccb2c7f..5f5856df 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -285,6 +285,7 @@ ISL_DECLARE_MULTI(aff) __isl_give isl_multi_aff *isl_multi_aff_from_aff(__isl_take isl_aff *aff); __isl_give isl_multi_aff *isl_multi_aff_identity(__isl_take isl_space *space); +__isl_give isl_multi_aff *isl_multi_aff_domain_map(__isl_take isl_space *space); int isl_multi_aff_plain_is_equal(__isl_keep isl_multi_aff *maff1, __isl_keep isl_multi_aff *maff2); diff --git a/isl_aff.c b/isl_aff.c index 668d8ff8..d2ca1399 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -3245,6 +3245,46 @@ error: #include +/* Given a map space, return an isl_multi_aff that maps a wrapped copy + * of the space to its domain. + */ +__isl_give isl_multi_aff *isl_multi_aff_domain_map(__isl_take isl_space *space) +{ + int i, n_in; + isl_local_space *ls; + isl_multi_aff *ma; + + if (!space) + return NULL; + if (!isl_space_is_map(space)) + isl_die(isl_space_get_ctx(space), isl_error_invalid, + "not a map space", goto error); + + n_in = isl_space_dim(space, isl_dim_in); + space = isl_space_domain_map(space); + + ma = isl_multi_aff_alloc(isl_space_copy(space)); + if (n_in == 0) { + isl_space_free(space); + return ma; + } + + space = isl_space_domain(space); + ls = isl_local_space_from_space(space); + for (i = 0; i < n_in; ++i) { + isl_aff *aff; + + aff = isl_aff_var_on_domain(isl_local_space_copy(ls), + isl_dim_set, i); + ma = isl_multi_aff_set_aff(ma, i, aff); + } + isl_local_space_free(ls); + return ma; +error: + isl_space_free(space); + return NULL; +} + /* Create an isl_pw_multi_aff with the given isl_multi_aff on a universe * domain. */ -- 2.11.4.GIT