From 96d77f3413d7c3d0d383504b9e9d9c874128d1d9 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 4 Jun 2011 18:18:04 +0200 Subject: [PATCH] add isl_printer_print_schedule Signed-off-by: Sven Verdoolaege --- doc/user.pod | 6 +++++ include/isl/schedule.h | 4 +++ isl_schedule.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 899fb58..b885501 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2919,6 +2919,12 @@ from an C using the following function. __isl_give isl_union_map *isl_schedule_get_map( __isl_keep isl_schedule *sched); +A representation of the schedule can be printed using + + __isl_give isl_printer *isl_printer_print_schedule( + __isl_take isl_printer *p, + __isl_keep isl_schedule *schedule); + A representation of the schedule as a forest of bands can be obtained using the following function. diff --git a/include/isl/schedule.h b/include/isl/schedule.h index 6899cfd..3aa99a2 100644 --- a/include/isl/schedule.h +++ b/include/isl/schedule.h @@ -26,6 +26,10 @@ int isl_schedule_n_band(__isl_keep isl_schedule *sched); __isl_give isl_union_map *isl_schedule_get_band(__isl_keep isl_schedule *sched, unsigned band); +__isl_give isl_printer *isl_printer_print_schedule(__isl_take isl_printer *p, + __isl_keep isl_schedule *schedule); +void isl_schedule_dump(__isl_keep isl_schedule *schedule); + #if defined(__cplusplus) } #endif diff --git a/isl_schedule.c b/isl_schedule.c index 0b1ff56..bb747de 100644 --- a/isl_schedule.c +++ b/isl_schedule.c @@ -2621,3 +2621,72 @@ __isl_give isl_band_list *isl_schedule_get_band_forest( schedule->band_forest = construct_forest(schedule); return isl_band_list_copy(schedule->band_forest); } + +static __isl_give isl_printer *print_band_list(__isl_take isl_printer *p, + __isl_keep isl_band_list *list); + +static __isl_give isl_printer *print_band(__isl_take isl_printer *p, + __isl_keep isl_band *band) +{ + isl_band_list *children; + + p = isl_printer_start_line(p); + p = isl_printer_print_union_map(p, band->map); + p = isl_printer_end_line(p); + + if (!isl_band_has_children(band)) + return p; + + children = isl_band_get_children(band); + + p = isl_printer_indent(p, 4); + p = print_band_list(p, children); + p = isl_printer_indent(p, -4); + + isl_band_list_free(children); + + return p; +} + +static __isl_give isl_printer *print_band_list(__isl_take isl_printer *p, + __isl_keep isl_band_list *list) +{ + int i, n; + + n = isl_band_list_n_band(list); + for (i = 0; i < n; ++i) { + isl_band *band; + band = isl_band_list_get_band(list, i); + p = print_band(p, band); + isl_band_free(band); + } + + return p; +} + +__isl_give isl_printer *isl_printer_print_schedule(__isl_take isl_printer *p, + __isl_keep isl_schedule *schedule) +{ + isl_band_list *forest; + + forest = isl_schedule_get_band_forest(schedule); + + p = print_band_list(p, forest); + + isl_band_list_free(forest); + + return p; +} + +void isl_schedule_dump(__isl_keep isl_schedule *schedule) +{ + isl_printer *printer; + + if (!schedule) + return; + + printer = isl_printer_to_file(isl_schedule_get_ctx(schedule), stderr); + printer = isl_printer_print_schedule(printer, schedule); + + isl_printer_free(printer); +} -- 2.7.4