/* * Copyright 2011 INRIA Saclay * Copyright 2012-2014 Ecole Normale Superieure * Copyright 2016 Sven Verdoolaege * * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, * 91893 Orsay, France * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France */ #include <isl/ctx.h> #include <isl/val.h> #include <isl_aff_private.h> #include <isl/map.h> #include <isl/set.h> #include <isl/schedule.h> #include <isl/schedule_node.h> #include <isl_sort.h> #include <isl/printer.h> #include <isl_schedule_private.h> #include <isl_schedule_tree.h> #include <isl_schedule_node_private.h> /* Return a schedule encapsulating the given schedule tree. * * We currently only allow schedule trees with a domain or extension as root. * * The leaf field is initialized as a leaf node so that it can be * used to represent leaves in the constructed schedule. * The reference count is set to -1 since the isl_schedule_tree * should never be freed. It is up to the (internal) users of * these leaves to ensure that they are only used while the schedule * is still alive. */ __isl_give isl_schedule *isl_schedule_from_schedule_tree(isl_ctx *ctx, __isl_take isl_schedule_tree *tree) { … } /* Return a pointer to a schedule with as single node * a domain node with the given domain. */ __isl_give isl_schedule *isl_schedule_from_domain( __isl_take isl_union_set *domain) { … } /* Return a pointer to a schedule with as single node * a domain node with an empty domain. */ __isl_give isl_schedule *isl_schedule_empty(__isl_take isl_space *space) { … } /* Return a new reference to "sched". */ __isl_give isl_schedule *isl_schedule_copy(__isl_keep isl_schedule *sched) { … } /* Return an isl_schedule that is equal to "schedule" and that has only * a single reference. */ __isl_give isl_schedule *isl_schedule_cow(__isl_take isl_schedule *schedule) { … } __isl_null isl_schedule *isl_schedule_free(__isl_take isl_schedule *sched) { … } /* Replace the root of "schedule" by "tree". */ __isl_give isl_schedule *isl_schedule_set_root( __isl_take isl_schedule *schedule, __isl_take isl_schedule_tree *tree) { … } isl_ctx *isl_schedule_get_ctx(__isl_keep isl_schedule *schedule) { … } /* Return a pointer to the leaf of "schedule". */ __isl_keep isl_schedule_tree *isl_schedule_peek_leaf( __isl_keep isl_schedule *schedule) { … } /* Are "schedule1" and "schedule2" obviously equal to each other? */ isl_bool isl_schedule_plain_is_equal(__isl_keep isl_schedule *schedule1, __isl_keep isl_schedule *schedule2) { … } /* Return the (parameter) space of the schedule, i.e., the space * of the root domain. */ __isl_give isl_space *isl_schedule_get_space( __isl_keep isl_schedule *schedule) { … } /* Return a pointer to the root of "schedule". */ __isl_give isl_schedule_node *isl_schedule_get_root( __isl_keep isl_schedule *schedule) { … } /* Return the domain of the root domain node of "schedule". */ __isl_give isl_union_set *isl_schedule_get_domain( __isl_keep isl_schedule *schedule) { … } /* Traverse all nodes of "sched" 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 * at that node is skipped. * * Return 0 on success and -1 on failure. */ isl_stat isl_schedule_foreach_schedule_node_top_down( __isl_keep isl_schedule *sched, isl_bool (*fn)(__isl_keep isl_schedule_node *node, void *user), void *user) { … } /* Traverse the node of "sched" in depth first postorder, * allowing the user to modify the visited node. * The traversal continues from the node returned by the callback function. * It is the responsibility of the user to ensure that this does not * lead to an infinite loop. It is safest to always return a pointer * to the same position (same ancestors and child positions) as the input node. */ __isl_give isl_schedule *isl_schedule_map_schedule_node_bottom_up( __isl_take isl_schedule *schedule, __isl_give isl_schedule_node *(*fn)( __isl_take isl_schedule_node *node, void *user), void *user) { … } /* Wrapper around isl_schedule_node_reset_user for use as * an isl_schedule_map_schedule_node_bottom_up callback. */ static __isl_give isl_schedule_node *reset_user( __isl_take isl_schedule_node *node, void *user) { … } /* Reset the user pointer on all identifiers of parameters and tuples * in the schedule "schedule". */ __isl_give isl_schedule *isl_schedule_reset_user( __isl_take isl_schedule *schedule) { … } /* Wrapper around isl_schedule_node_align_params for use as * an isl_schedule_map_schedule_node_bottom_up callback. */ static __isl_give isl_schedule_node *align_params( __isl_take isl_schedule_node *node, void *user) { … } /* Align the parameters of all nodes in schedule "schedule" * to those of "space". */ __isl_give isl_schedule *isl_schedule_align_params( __isl_take isl_schedule *schedule, __isl_take isl_space *space) { … } /* Wrapper around isl_schedule_node_pullback_union_pw_multi_aff for use as * an isl_schedule_map_schedule_node_bottom_up callback. */ static __isl_give isl_schedule_node *pullback_upma( __isl_take isl_schedule_node *node, void *user) { … } /* Compute the pullback of "schedule" by the function represented by "upma". * In other words, plug in "upma" in the iteration domains of "schedule". * * The schedule tree is not allowed to contain any expansion nodes. */ __isl_give isl_schedule *isl_schedule_pullback_union_pw_multi_aff( __isl_take isl_schedule *schedule, __isl_take isl_union_pw_multi_aff *upma) { … } /* Expand the schedule "schedule" by extending all leaves * with an expansion node with as subtree the tree of "expansion". * The expansion of the expansion node is determined by "contraction" * and the domain of "expansion". That is, the domain of "expansion" * is contracted according to "contraction". * * Call isl_schedule_node_expand after extracting the required * information from "expansion". */ __isl_give isl_schedule *isl_schedule_expand(__isl_take isl_schedule *schedule, __isl_take isl_union_pw_multi_aff *contraction, __isl_take isl_schedule *expansion) { … } /* Intersect the domain of the schedule "schedule" with "domain". * The root of "schedule" is required to be a domain node. */ __isl_give isl_schedule *isl_schedule_intersect_domain( __isl_take isl_schedule *schedule, __isl_take isl_union_set *domain) { … } /* Replace the domain of the schedule "schedule" with the gist * of the original domain with respect to the parameter domain "context". */ __isl_give isl_schedule *isl_schedule_gist_domain_params( __isl_take isl_schedule *schedule, __isl_take isl_set *context) { … } /* Return an isl_union_map representation of the schedule. In particular, * return an isl_union_map corresponding to the subtree schedule of the child * of the root domain node. That is, we do not intersect the domain * of the returned isl_union_map with the domain constraints. */ __isl_give isl_union_map *isl_schedule_get_map(__isl_keep isl_schedule *sched) { … } /* Insert a band node with partial schedule "partial" between the domain * root node of "schedule" and its single child. * Return a pointer to the updated schedule. * * If any of the nodes in the tree depend on the set of outer band nodes * then we refuse to insert the band node. */ __isl_give isl_schedule *isl_schedule_insert_partial_schedule( __isl_take isl_schedule *schedule, __isl_take isl_multi_union_pw_aff *partial) { … } /* Insert a context node with constraints "context" between the domain * root node of "schedule" and its single child. * Return a pointer to the updated schedule. */ __isl_give isl_schedule *isl_schedule_insert_context( __isl_take isl_schedule *schedule, __isl_take isl_set *context) { … } /* Insert a guard node with constraints "guard" between the domain * root node of "schedule" and its single child. * Return a pointer to the updated schedule. */ __isl_give isl_schedule *isl_schedule_insert_guard( __isl_take isl_schedule *schedule, __isl_take isl_set *guard) { … } /* Return a tree with as top-level node a filter corresponding to "filter" and * as child, the (single) child of "tree". * However, if this single child is of type "type", then the filter is inserted * in the children of this single child instead. */ static __isl_give isl_schedule_tree *insert_filter_in_child_of_type( __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter, enum isl_schedule_node_type type) { … } /* Construct a schedule that combines the schedules "schedule1" and "schedule2" * with a top-level node (underneath the domain node) of type "type", * either isl_schedule_node_sequence or isl_schedule_node_set. * The domains of the two schedules are assumed to be disjoint. * * The new schedule has as domain the union of the domains of the two * schedules. The child of the domain node is a node of type "type" * with two filters corresponding to the domains of the input schedules. * If one (or both) of the top-level nodes of the two schedules is itself * of type "type", then the filter is pushed into the children of that * node and the sequence or set is flattened. */ __isl_give isl_schedule *isl_schedule_pair(enum isl_schedule_node_type type, __isl_take isl_schedule *schedule1, __isl_take isl_schedule *schedule2) { … } /* Construct a schedule that combines the schedules "schedule1" and "schedule2" * through a sequence node. * The domains of the input schedules are assumed to be disjoint. */ __isl_give isl_schedule *isl_schedule_sequence( __isl_take isl_schedule *schedule1, __isl_take isl_schedule *schedule2) { … } /* Construct a schedule that combines the schedules "schedule1" and "schedule2" * through a set node. * The domains of the input schedules are assumed to be disjoint. */ __isl_give isl_schedule *isl_schedule_set( __isl_take isl_schedule *schedule1, __isl_take isl_schedule *schedule2) { … } /* Print "schedule" to "p". */ __isl_give isl_printer *isl_printer_print_schedule(__isl_take isl_printer *p, __isl_keep isl_schedule *schedule) { … } #undef BASE #define BASE … #include <print_templ_yaml.c>