From c0be10f478bdcdfaeb2021bd21e2eacefa814800 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 1 Jul 2015 16:57:21 +0200 Subject: [PATCH] extract out isl_union_eval.c This makes the function isl_union_*_eval opt-in rather than opt-out. Signed-off-by: Sven Verdoolaege --- Makefile.am | 1 + isl_aff.c | 4 ---- isl_fold.c | 1 + isl_polynomial.c | 1 + isl_union_eval.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ isl_union_templ.c | 54 --------------------------------------------------- 6 files changed, 61 insertions(+), 58 deletions(-) create mode 100644 isl_union_eval.c diff --git a/Makefile.am b/Makefile.am index 0b1ec4de..7753aea0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -325,6 +325,7 @@ EXTRA_DIST = \ isl_pw_templ.c \ isl_union_macro.h \ isl_union_templ.c \ + isl_union_eval.c \ isl.py \ doc/CodingStyle \ doc/SubmittingPatches \ diff --git a/isl_aff.c b/isl_aff.c index d1d293fd..e252a213 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -2578,8 +2578,6 @@ __isl_give isl_pw_aff *isl_pw_aff_from_aff(__isl_take isl_aff *aff) #undef PARTS #define PARTS pw_aff -#define NO_EVAL - #include static __isl_give isl_set *align_params_pw_pw_set_and( @@ -4074,8 +4072,6 @@ __isl_give isl_set *isl_multi_aff_lex_ge_set(__isl_take isl_multi_aff *ma1, #undef PARTS #define PARTS pw_multi_aff -#define NO_EVAL - #include /* Given a function "cmp" that returns the set of elements where diff --git a/isl_fold.c b/isl_fold.c index 4d44112a..a89c507a 100644 --- a/isl_fold.c +++ b/isl_fold.c @@ -685,6 +685,7 @@ __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params( #define NO_SUB #include +#include __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_empty(enum isl_fold type, __isl_take isl_space *dim) diff --git a/isl_polynomial.c b/isl_polynomial.c index 414e7c0b..eb848de9 100644 --- a/isl_polynomial.c +++ b/isl_polynomial.c @@ -2818,6 +2818,7 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial( #define PARTS pw_qpolynomial #include +#include int isl_pw_qpolynomial_is_one(__isl_keep isl_pw_qpolynomial *pwqp) { diff --git a/isl_union_eval.c b/isl_union_eval.c new file mode 100644 index 00000000..3daab3fc --- /dev/null +++ b/isl_union_eval.c @@ -0,0 +1,58 @@ +/* + * Copyright 2010 INRIA Saclay + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, + * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, + * 91893 Orsay, France + */ + +#include + +/* Is the domain space of "entry" equal to "space"? + */ +static int FN(UNION,has_domain_space)(const void *entry, const void *val) +{ + PART *part = (PART *)entry; + isl_space *space = (isl_space *) val; + + if (isl_space_is_params(space)) + return isl_space_is_set(part->dim); + + return isl_space_tuple_is_equal(part->dim, isl_dim_in, + space, isl_dim_set); +} + +__isl_give isl_val *FN(UNION,eval)(__isl_take UNION *u, + __isl_take isl_point *pnt) +{ + uint32_t hash; + struct isl_hash_table_entry *entry; + isl_space *space; + isl_val *v; + + if (!u || !pnt) + goto error; + + space = isl_space_copy(pnt->dim); + if (!space) + goto error; + hash = isl_space_get_hash(space); + entry = isl_hash_table_find(u->space->ctx, &u->table, + hash, &FN(UNION,has_domain_space), + space, 0); + isl_space_free(space); + if (!entry) { + v = isl_val_zero(isl_point_get_ctx(pnt)); + isl_point_free(pnt); + } else { + v = FN(PART,eval)(FN(PART,copy)(entry->data), pnt); + } + FN(UNION,free)(u); + return v; +error: + FN(UNION,free)(u); + isl_point_free(pnt); + return NULL; +} diff --git a/isl_union_templ.c b/isl_union_templ.c index c05d4e4c..9b1d5179 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -153,25 +153,6 @@ isl_stat FN(FN(UNION,foreach),PARTS)(__isl_keep UNION *u, &FN(UNION,call_on_copy), &data); } -/* This function is not currently used by isl_aff.c. - */ -static int FN(UNION,has_domain_space)(const void *entry, const void *val) - __attribute__ ((unused)); - -/* Is the domain space of "entry" equal to "space"? - */ -static int FN(UNION,has_domain_space)(const void *entry, const void *val) -{ - PART *part = (PART *)entry; - isl_space *space = (isl_space *) val; - - if (isl_space_is_params(space)) - return isl_space_is_set(part->dim); - - return isl_space_tuple_is_equal(part->dim, isl_dim_in, - space, isl_dim_set); -} - /* Is the domain space of "entry" equal to the domain of "space"? */ static int FN(UNION,has_same_domain_space)(const void *entry, const void *val) @@ -882,41 +863,6 @@ __isl_give UNION *FN(UNION,gist)(__isl_take UNION *u, return FN(UNION,match_domain_op)(u, uset, &FN(PW,gist)); } -#ifndef NO_EVAL -__isl_give isl_val *FN(UNION,eval)(__isl_take UNION *u, - __isl_take isl_point *pnt) -{ - uint32_t hash; - struct isl_hash_table_entry *entry; - isl_space *space; - isl_val *v; - - if (!u || !pnt) - goto error; - - space = isl_space_copy(pnt->dim); - if (!space) - goto error; - hash = isl_space_get_hash(space); - entry = isl_hash_table_find(u->space->ctx, &u->table, - hash, &FN(UNION,has_domain_space), - space, 0); - isl_space_free(space); - if (!entry) { - v = isl_val_zero(isl_point_get_ctx(pnt)); - isl_point_free(pnt); - } else { - v = FN(PART,eval)(FN(PART,copy)(entry->data), pnt); - } - FN(UNION,free)(u); - return v; -error: - FN(UNION,free)(u); - isl_point_free(pnt); - return NULL; -} -#endif - /* Coalesce an entry in a UNION. Coalescing is performed in-place. * Since the UNION may have several references, the entry is only * replaced if the coalescing is successful. -- 2.11.4.GIT