add isl_schedule_node_order_before
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 15 Dec 2015 11:07:09 +0000 (15 12:07 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 4 Jan 2016 11:13:25 +0000 (4 12:13 +0100)
This function is similar to isl_schedule_node_order_after,
except that it puts the specified elements before the others
instead of after.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/schedule_node.h
isl_schedule_node.c

index 81e4674..b601c10 100644 (file)
@@ -8336,14 +8336,20 @@ position as the node pointed to by C<node> in the original tree.
 
        #include <isl/schedule_node.h>
        __isl_give isl_schedule_node *
+       isl_schedule_node_order_before(
+               __isl_take isl_schedule_node *node,
+               __isl_take isl_union_set *filter);
+       __isl_give isl_schedule_node *
        isl_schedule_node_order_after(
                __isl_take isl_schedule_node *node,
                __isl_take isl_union_set *filter);
 
-This function splits the domain elements that reach C<node>
+These functions split the domain elements that reach C<node>
 into those that satisfy C<filter> and those that do not and
 arranges for the elements that do satisfy the filter to be
-executed after those that do not.  The order is imposed by
+executed before (in case of C<isl_schedule_node_order_before>)
+or after (in case of C<isl_schedule_node_order_after>)
+those that do not.  The order is imposed by
 a sequence node, possibly reusing the grandparent of C<node>
 on two copies of the subtree attached to the original C<node>.
 Both copies are simplified with respect to their filter.
index 0b92785..b1476e9 100644 (file)
@@ -205,6 +205,8 @@ __isl_give isl_schedule_node *isl_schedule_node_cut(
 __isl_give isl_schedule_node *isl_schedule_node_delete(
        __isl_take isl_schedule_node *node);
 
+__isl_give isl_schedule_node *isl_schedule_node_order_before(
+       __isl_take isl_schedule_node *node, __isl_take isl_union_set *filter);
 __isl_give isl_schedule_node *isl_schedule_node_order_after(
        __isl_take isl_schedule_node *node, __isl_take isl_union_set *filter);
 
index 91448c2..65ebe29 100644 (file)
@@ -4213,7 +4213,8 @@ __isl_give isl_schedule_node *isl_schedule_node_graft_after(
 
 /* Split the domain elements that reach "node" into those that satisfy
  * "filter" and those that do not.  Arrange for the first subset to be
- * executed after the second subset.
+ * executed before or after the second subset, depending on the value
+ * of "before".
  * Return a pointer to the tree corresponding to the second subset,
  * except when this subset is empty in which case the original pointer
  * is returned.
@@ -4224,8 +4225,9 @@ __isl_give isl_schedule_node *isl_schedule_node_graft_after(
  * The children in the sequence are copies of the original subtree,
  * simplified with respect to their filters.
  */
-__isl_give isl_schedule_node *isl_schedule_node_order_after(
-       __isl_take isl_schedule_node *node, __isl_take isl_union_set *filter)
+static __isl_give isl_schedule_node *isl_schedule_node_order_before_or_after(
+       __isl_take isl_schedule_node *node, __isl_take isl_union_set *filter,
+       int before)
 {
        enum isl_schedule_node_type ancestors[] =
                { isl_schedule_node_filter, isl_schedule_node_sequence };
@@ -4269,9 +4271,14 @@ __isl_give isl_schedule_node *isl_schedule_node_order_after(
        isl_schedule_node_free(node2);
        tree1 = isl_schedule_tree_insert_filter(tree1, node_filter);
        tree2 = isl_schedule_tree_insert_filter(tree2, filter);
-       tree1 = isl_schedule_tree_sequence_pair(tree1, tree2);
 
-       node = graft_or_splice(node, tree1, 0);
+       if (before) {
+               tree1 = isl_schedule_tree_sequence_pair(tree2, tree1);
+               node = graft_or_splice(node, tree1, 1);
+       } else {
+               tree1 = isl_schedule_tree_sequence_pair(tree1, tree2);
+               node = graft_or_splice(node, tree1, 0);
+       }
 
        return node;
 error:
@@ -4281,6 +4288,32 @@ error:
        return NULL;
 }
 
+/* Split the domain elements that reach "node" into those that satisfy
+ * "filter" and those that do not.  Arrange for the first subset to be
+ * executed before the second subset.
+ * Return a pointer to the tree corresponding to the second subset,
+ * except when this subset is empty in which case the original pointer
+ * is returned.
+ */
+__isl_give isl_schedule_node *isl_schedule_node_order_before(
+       __isl_take isl_schedule_node *node, __isl_take isl_union_set *filter)
+{
+       return isl_schedule_node_order_before_or_after(node, filter, 1);
+}
+
+/* Split the domain elements that reach "node" into those that satisfy
+ * "filter" and those that do not.  Arrange for the first subset to be
+ * executed after the second subset.
+ * Return a pointer to the tree corresponding to the second subset,
+ * except when this subset is empty in which case the original pointer
+ * is returned.
+ */
+__isl_give isl_schedule_node *isl_schedule_node_order_after(
+       __isl_take isl_schedule_node *node, __isl_take isl_union_set *filter)
+{
+       return isl_schedule_node_order_before_or_after(node, filter, 0);
+}
+
 /* Reset the user pointer on all identifiers of parameters and tuples
  * in the schedule node "node".
  */