From 92ebec9e6cf1bf8da13298ac68c30211372ec68c Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 3 Dec 2013 11:25:46 +0100 Subject: [PATCH] add isl_aff_find_dim_by_name Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/aff.h | 3 +++ isl_aff.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 699495d1..419a4d1a 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1269,6 +1269,8 @@ its position can be obtained from the following functions. int isl_multi_pw_aff_find_dim_by_id( __isl_keep isl_multi_pw_aff *mpa, enum isl_dim_type type, __isl_keep isl_id *id); + int isl_aff_find_dim_by_name(__isl_keep isl_aff *aff, + enum isl_dim_type type, const char *name); The identifiers or names of entire spaces may be set or read off using the following functions. diff --git a/include/isl/aff.h b/include/isl/aff.h index fbd83c00..eb8e8611 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -69,6 +69,9 @@ __isl_give isl_aff *isl_aff_set_dim_name(__isl_take isl_aff *aff, __isl_give isl_aff *isl_aff_set_dim_id(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, __isl_take isl_id *id); +int isl_aff_find_dim_by_name(__isl_keep isl_aff *aff, enum isl_dim_type type, + const char *name); + int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2); int isl_aff_plain_is_zero(__isl_keep isl_aff *aff); int isl_aff_is_nan(__isl_keep isl_aff *aff); diff --git a/isl_aff.c b/isl_aff.c index b82475f9..7c785047 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -276,6 +276,22 @@ int isl_aff_dim(__isl_keep isl_aff *aff, enum isl_dim_type type) return isl_local_space_dim(aff->ls, type); } +/* Return the position of the dimension of the given type and name + * in "aff". + * Return -1 if no such dimension can be found. + */ +int isl_aff_find_dim_by_name(__isl_keep isl_aff *aff, enum isl_dim_type type, + const char *name) +{ + if (!aff) + return -1; + if (type == isl_dim_out) + return -1; + if (type == isl_dim_in) + type = isl_dim_set; + return isl_local_space_find_dim_by_name(aff->ls, type, name); +} + __isl_give isl_space *isl_aff_get_domain_space(__isl_keep isl_aff *aff) { return aff ? isl_local_space_get_space(aff->ls) : NULL; -- 2.11.4.GIT