tc/core/polyhedral/schedule_isl_conversion.cc
/*
 * Convert the extension node "st" along with its descendants
 * to nodes in an isl schedule tree and insert them at position "node".
 * The extension node is assumed to have a sequence node as child
 * with some children (exclusively) referring
 * to the original domain elements (those that reach "node").
 * Convert this subsequence first and then graft the intermediate
 * elements after the corresponding node in the converted sequence,
 * the earlier elements before the sequence and
 * the later elements after.
 */
Convert the extension node "st" along with its descendants
to nodes in an isl schedule tree and insert them at position "node".
The extension node is assumed to have a sequence node as child
with some children (exclusively) referring
to the original domain elements (those that reach "node").
Convert this subsequence first and then graft the intermediate
elements after the corresponding node in the converted sequence,
the earlier elements before the sequence and
the later elements after.
Convert the extension node " st " along with its descendants to nodes in an isl schedule tree and insert them at position " node " . The extension node is assumed to have a sequence node as child with some children ( exclusively ) referring to the original domain elements ( those that reach " node " ) . Convert this subsequence first and then graft the intermediate elements after the corresponding node in the converted sequence the earlier elements before the sequence and the later elements after .
isl::schedule_node insertExtension(
    isl::schedule_node node,
    const ScheduleTree* st) {
  auto depth0 = node.get_tree_depth();
  auto domain = node.get_universe_domain();
  auto child = st->child({0});
  auto corePos = findCorePositions(child, domain);
  CHECK(!corePos.empty());
  node = insertBranch(node, child, corePos);
  auto extension = st->elemAs<ScheduleTreeElemExtension>()->extension_;
  for (size_t i = 0; i < corePos.size() - 1; ++i) {
    auto depth0 = node.get_tree_depth();
    node = node.child(i).child(0);
    for (auto j = corePos[i] + 1; j < corePos[i + 1]; ++j) {
      auto graft = graftFromFilterSubtree(child->child({j}), extension);
      node = node.graft_after(graft);
    }
    node = node.ancestor(node.get_tree_depth() - depth0);
  }
  for (size_t i = 0; i < corePos[0]; ++i) {
    auto graft = graftFromFilterSubtree(child->child({i}), extension);
    node = node.graft_before(graft);
  }
  for (auto i = child->numChildren(); i > corePos.back() + 1; --i) {
    auto graft = graftFromFilterSubtree(child->child({i - 1}), extension);
    node = node.graft_after(graft);
  }
  node = node.ancestor(node.get_tree_depth() - depth0);
  return node;
}
isl :: schedule_node insertExtension ( isl :: schedule_node node , const ScheduleTree * st ) { auto depth0 = node . get_tree_depth ( ) ; auto domain = node . get_universe_domain ( ) ; auto child = st -> child ( { 0 } ) ; auto corePos = findCorePositions ( child , domain ) ; CHECK ( ! corePos . empty ( ) ) ; node = insertBranch ( node , child , corePos ) ; auto extension = st -> elemAs < ScheduleTreeElemExtension > ( ) -> extension_ ; for ( size_t i = 0 ; i < corePos . size ( ) - 1 ; ++ i ) { auto depth0 = node . get_tree_depth ( ) ; node = node . child ( i ) . child ( 0 ) ; for ( auto j = corePos [ i ] + 1 ; j < corePos [ i + 1 ] ; ++ j ) { auto graft = graftFromFilterSubtree ( child -> child ( { j } ) , extension ) ; node = node . graft_after ( graft ) ; } node = node . ancestor ( node . get_tree_depth ( ) - depth0 ) ; } for ( size_t i = 0 ; i < corePos [ 0 ] ; ++ i ) { auto graft = graftFromFilterSubtree ( child -> child ( { i } ) , extension ) ; node = node . graft_before ( graft ) ; } for ( auto i = child -> numChildren ( ) ; i > corePos . back ( ) + 1 ; -- i ) { auto graft = graftFromFilterSubtree ( child -> child ( { i - 1 } ) , extension ) ; node = node . graft_after ( graft ) ; } node = node . ancestor ( node . get_tree_depth ( ) - depth0 ) ; return node ; }
Convert the extension node "st" along with its descendants
 to nodes in an isl schedule tree and insert them at position "node".
Convert the extension node " st " along with its descendants to nodes in an isl schedule tree and insert them at position " node " .