From 203e64dd083e6ae9e2608eda5fe0fdee3c2c193f Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 20 Mar 2012 16:00:45 +0100 Subject: [PATCH] add isl_band_list_foreach_band Signed-off-by: Sven Verdoolaege --- doc/user.pod | 7 +++++++ include/isl/band.h | 3 +++ isl_band.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 83d0a4f7..acff5600 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -4457,12 +4457,19 @@ The properties of a band can be inspected using the following functions. int isl_band_member_is_zero_distance( __isl_keep isl_band *band, int pos); + int isl_band_list_foreach_band( + __isl_keep isl_band_list *list, + int (*fn)(__isl_keep isl_band *band, void *user), + void *user); + Note that a scheduling dimension is considered to be ``zero distance'' if it does not carry any proximity dependences within its band. That is, if the dependence distances of the proximity dependences are all zero in that direction (for fixed iterations of outer bands). +The function C calls C on the bands +in depth-first post-order. A band can be tiled using the following function. diff --git a/include/isl/band.h b/include/isl/band.h index 7dbb62ad..e7bf51c1 100644 --- a/include/isl/band.h +++ b/include/isl/band.h @@ -37,6 +37,9 @@ int isl_band_tile(__isl_keep isl_band *band, __isl_take isl_vec *sizes); int isl_band_n_member(__isl_keep isl_band *band); int isl_band_member_is_zero_distance(__isl_keep isl_band *band, int pos); +int isl_band_list_foreach_band(__isl_keep isl_band_list *list, + int (*fn)(__isl_keep isl_band *band, void *user), void *user); + __isl_give isl_printer *isl_printer_print_band(__isl_take isl_printer *p, __isl_keep isl_band *band); void isl_band_dump(__isl_keep isl_band *band); diff --git a/isl_band.c b/isl_band.c index e381c609..5281e6eb 100644 --- a/isl_band.c +++ b/isl_band.c @@ -284,6 +284,44 @@ __isl_give isl_union_map *isl_band_get_suffix_schedule( return isl_union_map_from_union_pw_multi_aff(suffix); } +/* Call "fn" on each band (recursively) in the list + * in depth-first post-order. + */ +int isl_band_list_foreach_band(__isl_keep isl_band_list *list, + int (*fn)(__isl_keep isl_band *band, void *user), void *user) +{ + int i, n; + + if (!list) + return -1; + + n = isl_band_list_n_band(list); + for (i = 0; i < n; ++i) { + isl_band *band; + int r = 0; + + band = isl_band_list_get_band(list, i); + if (isl_band_has_children(band)) { + isl_band_list *children; + + children = isl_band_get_children(band); + r = isl_band_list_foreach_band(children, fn, user); + isl_band_list_free(children); + } + + if (!band) + r = -1; + if (r == 0) + r = fn(band, user); + + isl_band_free(band); + if (r) + return r; + } + + return 0; +} + /* Internal data used during the construction of the schedule * for the tile loops. * -- 2.11.4.GIT