From 3cdf14f9968f3beb3c45a6435c97e4b6a941f983 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 14 Dec 2022 12:26:00 +0100 Subject: [PATCH] isl_multi_intersect.c: extract out isl_multi_*_check_compatible_domain This will be reused in the next commit. Signed-off-by: Sven Verdoolaege --- Makefile.am | 1 + isl_aff.c | 2 ++ isl_multi_check_domain_templ.c | 45 ++++++++++++++++++++++++++++++++++++++++++ isl_multi_intersect.c | 36 --------------------------------- 4 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 isl_multi_check_domain_templ.c diff --git a/Makefile.am b/Makefile.am index 6ea890cf..2751c7ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -563,6 +563,7 @@ EXTRA_DIST = \ isl_multi_arith_templ.c \ isl_multi_bin_val_templ.c \ isl_multi_bind_domain_templ.c \ + isl_multi_check_domain_templ.c \ isl_multi_cmp.c \ isl_multi_coalesce.c \ isl_multi_dim_id_templ.c \ diff --git a/isl_aff.c b/isl_aff.c index 729f2f7c..e691762d 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -6671,6 +6671,7 @@ error: #include #include #include +#include #include #include #include @@ -8616,6 +8617,7 @@ error: #include #include #include +#include #include #include #include diff --git a/isl_multi_check_domain_templ.c b/isl_multi_check_domain_templ.c new file mode 100644 index 00000000..3a6c4e67 --- /dev/null +++ b/isl_multi_check_domain_templ.c @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +#include + +/* Does the space of "domain" correspond to that of the domain of "multi"? + * The parameters do not need to be aligned. + */ +static isl_bool FN(MULTI(BASE),compatible_domain)( + __isl_keep MULTI(BASE) *multi, __isl_keep DOM *domain) +{ + isl_bool ok; + isl_space *space, *domain_space; + + domain_space = FN(DOM,get_space)(domain); + space = FN(MULTI(BASE),get_space)(multi); + ok = isl_space_has_domain_tuples(domain_space, space); + isl_space_free(space); + isl_space_free(domain_space); + + return ok; +} + +/* Check that the space of "domain" corresponds to + * that of the domain of "multi", ignoring parameters. + */ +static isl_stat FN(MULTI(BASE),check_compatible_domain)( + __isl_keep MULTI(BASE) *multi, __isl_keep DOM *domain) +{ + isl_bool ok; + + ok = FN(MULTI(BASE),compatible_domain)(multi, domain); + if (ok < 0) + return isl_stat_error; + if (!ok) + isl_die(FN(DOM,get_ctx)(domain), isl_error_invalid, + "incompatible spaces", return isl_stat_error); + + return isl_stat_ok; +} diff --git a/isl_multi_intersect.c b/isl_multi_intersect.c index d2c57207..c2992336 100644 --- a/isl_multi_intersect.c +++ b/isl_multi_intersect.c @@ -10,42 +10,6 @@ #include -/* Does the space of "domain" correspond to that of the domain of "multi"? - * The parameters do not need to be aligned. - */ -static isl_bool FN(MULTI(BASE),compatible_domain)( - __isl_keep MULTI(BASE) *multi, __isl_keep DOM *domain) -{ - isl_bool ok; - isl_space *space, *domain_space; - - domain_space = FN(DOM,get_space)(domain); - space = FN(MULTI(BASE),get_space)(multi); - ok = isl_space_has_domain_tuples(domain_space, space); - isl_space_free(space); - isl_space_free(domain_space); - - return ok; -} - -/* Check that the space of "domain" corresponds to - * that of the domain of "multi", ignoring parameters. - */ -static isl_stat FN(MULTI(BASE),check_compatible_domain)( - __isl_keep MULTI(BASE) *multi, __isl_keep DOM *domain) -{ - isl_bool ok; - - ok = FN(MULTI(BASE),compatible_domain)(multi, domain); - if (ok < 0) - return isl_stat_error; - if (!ok) - isl_die(FN(DOM,get_ctx)(domain), isl_error_invalid, - "incompatible spaces", return isl_stat_error); - - return isl_stat_ok; -} - /* Intersect the explicit domain of "multi" with "domain". * * In the case of an isl_multi_union_pw_aff object, the explicit domain -- 2.11.4.GIT