summaryrefslogtreecommitdiffstats
path: root/polly/lib/External/isl/isl_schedule_node.c
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/External/isl/isl_schedule_node.c')
-rw-r--r--polly/lib/External/isl/isl_schedule_node.c65
1 files changed, 60 insertions, 5 deletions
diff --git a/polly/lib/External/isl/isl_schedule_node.c b/polly/lib/External/isl/isl_schedule_node.c
index 3a53dfe3f91..4fa5a8e5fa9 100644
--- a/polly/lib/External/isl/isl_schedule_node.c
+++ b/polly/lib/External/isl/isl_schedule_node.c
@@ -11,6 +11,8 @@
* B.P. 105 - 78153 Le Chesnay, France
*/
+#include <isl/val.h>
+#include <isl/space.h>
#include <isl/set.h>
#include <isl_schedule_band.h>
#include <isl_schedule_private.h>
@@ -294,7 +296,7 @@ int isl_schedule_node_get_schedule_depth(__isl_keep isl_schedule_node *node)
*
* "initialized" is set if the filter field has been initialized.
* If "universe_domain" is not set, then the collected filter is intersected
- * with the the domain of the root domain node.
+ * with the domain of the root domain node.
* "universe_filter" is set if we are only collecting the universes of filters
* "collect_prefix" is set if we are collecting prefixes.
* "filter" collects all outer filters and is NULL until "initialized" is set.
@@ -1334,11 +1336,12 @@ static __isl_give isl_schedule_node *preorder_leave(
/* Traverse the descendants of "node" (including the node itself)
* in depth first preorder.
*
- * If "fn" returns -1 on any of the nodes, then the traversal is aborted.
- * If "fn" returns 0 on any of the nodes, then the subtree rooted
+ * If "fn" returns isl_bool_error on any of the nodes,
+ * then the traversal is aborted.
+ * If "fn" returns isl_bool_false on any of the nodes, then the subtree rooted
* at that node is skipped.
*
- * Return 0 on success and -1 on failure.
+ * Return isl_stat_ok on success and isl_stat_error on failure.
*/
isl_stat isl_schedule_node_foreach_descendant_top_down(
__isl_keep isl_schedule_node *node,
@@ -1354,6 +1357,56 @@ isl_stat isl_schedule_node_foreach_descendant_top_down(
return node ? isl_stat_ok : isl_stat_error;
}
+/* Internal data structure for isl_schedule_node_every_descendant.
+ *
+ * "test" is the user-specified callback function.
+ * "user" is the user-specified callback function argument.
+ *
+ * "failed" is initialized to 0 and set to 1 if "test" fails
+ * on any node.
+ */
+struct isl_union_map_every_data {
+ isl_bool (*test)(__isl_keep isl_schedule_node *node, void *user);
+ void *user;
+ int failed;
+};
+
+/* isl_schedule_node_foreach_descendant_top_down callback
+ * that sets data->failed if data->test returns false and
+ * subsequently aborts the traversal.
+ */
+static isl_bool call_every(__isl_keep isl_schedule_node *node, void *user)
+{
+ struct isl_union_map_every_data *data = user;
+ isl_bool r;
+
+ r = data->test(node, data->user);
+ if (r < 0)
+ return isl_bool_error;
+ if (r)
+ return isl_bool_true;
+ data->failed = 1;
+ return isl_bool_error;
+}
+
+/* Does "test" succeed on every descendant of "node" (including "node" itself)?
+ */
+isl_bool isl_schedule_node_every_descendant(__isl_keep isl_schedule_node *node,
+ isl_bool (*test)(__isl_keep isl_schedule_node *node, void *user),
+ void *user)
+{
+ struct isl_union_map_every_data data = { test, user, 0 };
+ isl_stat r;
+
+ r = isl_schedule_node_foreach_descendant_top_down(node, &call_every,
+ &data);
+ if (r >= 0)
+ return isl_bool_true;
+ if (data.failed)
+ return isl_bool_false;
+ return isl_bool_error;
+}
+
/* Internal data structure for isl_schedule_node_map_descendant_bottom_up.
*
* "fn" is the user-specified callback function.
@@ -1960,7 +2013,7 @@ __isl_give isl_schedule_node *isl_schedule_node_band_sink(
* dimensions and one with the remaining dimensions.
* The schedules of the two band nodes live in anonymous spaces.
* The loop AST generation type options and the isolate option
- * are split over the the two band nodes.
+ * are split over the two band nodes.
*/
__isl_give isl_schedule_node *isl_schedule_node_band_split(
__isl_take isl_schedule_node *node, int pos)
@@ -4286,6 +4339,8 @@ static __isl_give isl_schedule_node *isl_schedule_node_graft_before_or_after(
if (isl_schedule_node_get_type(graft) == isl_schedule_node_domain)
graft = extension_from_domain(graft, node);
+ if (!graft)
+ goto error;
if (isl_schedule_node_get_type(graft) != isl_schedule_node_extension)
isl_die(isl_schedule_node_get_ctx(node), isl_error_invalid,
"expecting domain or extension as root of graft",
OpenPOWER on IntegriCloud