From 90888f811830b131363944b61bece3ce68a210c2 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 24 Oct 2019 15:30:24 +0200 Subject: [PATCH] add isl_local_space_wrapped_reverse This will be used in the implementation of isl_aff_domain_reverse in the next commit. Signed-off-by: Sven Verdoolaege --- isl_local_space.c | 31 +++++++++++++++++++++++++++++++ isl_local_space_private.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/isl_local_space.c b/isl_local_space.c index 604e276a..e5abcb24 100644 --- a/isl_local_space.c +++ b/isl_local_space.c @@ -1,6 +1,7 @@ /* * Copyright 2011 INRIA Saclay * Copyright 2012-2014 Ecole Normale Superieure + * Copyright 2019 Cerebras Systems * * Use of this software is governed by the MIT license * @@ -8,6 +9,7 @@ * 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 + * and Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA */ #include @@ -1684,6 +1686,35 @@ __isl_give isl_local_space *isl_local_space_move_dims( return ls; } +/* Given a local space (A -> B), return the corresponding local space + * (B -> A). + */ +__isl_give isl_local_space *isl_local_space_wrapped_reverse( + __isl_take isl_local_space *ls) +{ + isl_space *space; + isl_local *local; + isl_size n_in, n_out; + unsigned offset; + + space = isl_local_space_peek_space(ls); + offset = isl_space_offset(space, isl_dim_set); + n_in = isl_space_wrapped_dim(space, isl_dim_set, isl_dim_in); + n_out = isl_space_wrapped_dim(space, isl_dim_set, isl_dim_out); + if (n_in < 0 || n_out < 0) + return isl_local_space_free(ls); + + space = isl_local_space_take_space(ls); + space = isl_space_wrapped_reverse(space); + ls = isl_local_space_restore_space(ls, space); + + local = isl_local_space_take_local(ls); + local = isl_local_move_vars(local, offset, offset + n_in, n_out); + ls = isl_local_space_restore_local(ls, local); + + return ls; +} + /* Remove any internal structure of the domain of "ls". * If there is any such internal structure in the input, * then the name of the corresponding space is also removed. diff --git a/isl_local_space_private.h b/isl_local_space_private.h index fbf2159c..1f644a0a 100644 --- a/isl_local_space_private.h +++ b/isl_local_space_private.h @@ -85,6 +85,8 @@ __isl_give isl_local_space *isl_local_space_lift( __isl_give isl_local_space *isl_local_space_preimage_multi_aff( __isl_take isl_local_space *ls, __isl_take isl_multi_aff *ma); +__isl_give isl_local_space *isl_local_space_wrapped_reverse( + __isl_take isl_local_space *ls); __isl_give isl_local_space *isl_local_space_move_dims( __isl_take isl_local_space *ls, enum isl_dim_type dst_type, unsigned dst_pos, -- 2.11.4.GIT