add isl_printer_print_schedule
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 4 Jun 2011 16:18:04 +0000 (18:18 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 5 Jun 2011 08:18:59 +0000 (10:18 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/schedule.h
isl_schedule.c

index 899fb58..b885501 100644 (file)
@@ -2919,6 +2919,12 @@ from an C<isl_schedule> 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.
 
index 6899cfd..3aa99a2 100644 (file)
@@ -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
index 0b1ff56..bb747de 100644 (file)
@@ -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);
+}