From c70f4c2d8d68ed4acd44ceab0299d739a49e168b Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 10 Jun 2014 14:39:28 +0200 Subject: [PATCH] add isl_union_pw_*_drop_dims Signed-off-by: Sven Verdoolaege --- doc/user.pod | 19 +++++++++++++++ include/isl/aff.h | 3 +++ include/isl/polynomial.h | 7 ++++++ isl_union_templ.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 8e9dcf22..f1f82a67 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -4937,6 +4937,11 @@ are not sufficient. __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims( __isl_take isl_pw_multi_aff *pma, enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_union_pw_multi_aff * + isl_union_pw_multi_aff_drop_dims( + __isl_take isl_union_pw_multi_aff *upma, + enum isl_dim_type type, + unsigned first, unsigned n); __isl_give isl_aff *isl_aff_move_dims( __isl_take isl_aff *aff, enum isl_dim_type dst_type, unsigned dst_pos, @@ -4958,6 +4963,20 @@ are not sufficient. enum isl_dim_type src_type, unsigned src_pos, unsigned n); + #include + __isl_give isl_union_pw_qpolynomial * + isl_union_pw_qpolynomial_drop_dims( + __isl_take isl_union_pw_qpolynomial *upwqp, + enum isl_dim_type type, + unsigned first, unsigned n); + __isl_give isl_union_pw_qpolynomial_fold * + isl_union_pw_qpolynomial_fold_drop_dims( + __isl_take isl_union_pw_qpolynomial_fold *upwf, + enum isl_dim_type type, + unsigned first, unsigned n); + +The operations on union expressions can only manipulate parameters. + =back =head2 Binary Operations diff --git a/include/isl/aff.h b/include/isl/aff.h index 7cdbb46c..0cde4694 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -555,6 +555,9 @@ int isl_union_pw_multi_aff_find_dim_by_name( __isl_keep isl_union_pw_multi_aff *upma, enum isl_dim_type type, const char *name); +__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_drop_dims( + __isl_take isl_union_pw_multi_aff *upma, + enum isl_dim_type type, unsigned first, unsigned n); __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_reset_user( __isl_take isl_union_pw_multi_aff *upma); diff --git a/include/isl/polynomial.h b/include/isl/polynomial.h index bf71046d..7895fa6d 100644 --- a/include/isl/polynomial.h +++ b/include/isl/polynomial.h @@ -507,6 +507,9 @@ int isl_union_pw_qpolynomial_find_dim_by_name( __isl_keep isl_union_pw_qpolynomial *upwqp, enum isl_dim_type type, const char *name); +__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_drop_dims( + __isl_take isl_union_pw_qpolynomial *upwqp, + enum isl_dim_type type, unsigned first, unsigned n); __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_reset_user( __isl_take isl_union_pw_qpolynomial *upwqp); @@ -595,6 +598,10 @@ int isl_union_pw_qpolynomial_fold_find_dim_by_name( enum isl_dim_type type, const char *name); __isl_give isl_union_pw_qpolynomial_fold * + isl_union_pw_qpolynomial_fold_drop_dims( + __isl_take isl_union_pw_qpolynomial_fold *upwf, + enum isl_dim_type type, unsigned first, unsigned n); +__isl_give isl_union_pw_qpolynomial_fold * isl_union_pw_qpolynomial_fold_reset_user( __isl_take isl_union_pw_qpolynomial_fold *upwf); diff --git a/isl_union_templ.c b/isl_union_templ.c index d478d4b6..ea7873a2 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -1,11 +1,13 @@ /* * Copyright 2010 INRIA Saclay + * Copyright 2013 Ecole Normale Superieure * * 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 + * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France */ #define xFN(TYPE,NAME) TYPE ## _ ## NAME @@ -1200,6 +1202,66 @@ __isl_give UNION *FN(UNION,neg)(__isl_take UNION *u) } #endif +/* Internal data structure for isl_union_*_drop_dims. + * type, first and n are passed to isl_*_drop_dims. + * res collects the results. + */ +S(UNION,drop_dims_data) { + enum isl_dim_type type; + unsigned first; + unsigned n; + + UNION *res; +}; + +/* Drop the parameters specified by "data" from "part" and + * add the results to data->res. + */ +static int FN(UNION,drop_dims_entry)(__isl_take PART *part, void *user) +{ + S(UNION,drop_dims_data) *data = user; + + part = FN(PART,drop_dims)(part, data->type, data->first, data->n); + data->res = FN(FN(UNION,add),PARTS)(data->res, part); + if (!data->res) + return -1; + + return 0; +} + +/* Drop the specified parameters from "u". + * That is, type is required to be isl_dim_param. + */ +__isl_give UNION *FN(UNION,drop_dims)( __isl_take UNION *u, + enum isl_dim_type type, unsigned first, unsigned n) +{ + isl_space *space; + S(UNION,drop_dims_data) data = { type, first, n }; + + if (!u) + return NULL; + + if (type != isl_dim_param) + isl_die(FN(UNION,get_ctx)(u), isl_error_invalid, + "can only project out parameters", + return FN(UNION,free)(u)); + + space = FN(UNION,get_space)(u); + space = isl_space_drop_dims(space, type, first, n); +#ifdef HAS_TYPE + data.res = FN(UNION,alloc)(space, u->type, u->table.n); +#else + data.res = FN(UNION,alloc)(space, u->table.n); +#endif + if (FN(FN(UNION,foreach),PARTS)(u, + &FN(UNION,drop_dims_entry), &data) < 0) + data.res = FN(UNION,free)(data.res); + + FN(UNION,free)(u); + + return data.res; +} + /* Reset the user pointer on all identifiers of parameters and tuples * of the space of "part" and add the result to *res. */ -- 2.11.4.GIT