Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit f33a7ec

Browse files
author
Sven Verdoolaege
committed
insertExtensionLabel{Before,After}: allow initial node to point at extension
This will be useful in insertCopiesUnder because the extension is introduced below a given node rather than above a given node. In a repeated application, the child of the node will point to the extension node introduced before.
1 parent 72e5dff commit f33a7ec

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tc/core/polyhedral/schedule_transforms.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ void insertExtensionLabelBefore(
588588
size_t pos;
589589
auto parent = tree->ancestor(root, 1);
590590
ScheduleTree* seqTree;
591+
if (tree->elemAs<detail::ScheduleTreeElemExtension>()) {
592+
tree = tree->child({0});
593+
parent = tree;
594+
}
591595
if (tree->elemAs<detail::ScheduleTreeElemSequence>()) {
592596
seqTree = tree;
593597
pos = 0;
@@ -610,6 +614,10 @@ void insertExtensionLabelAfter(
610614
size_t pos;
611615
auto parent = tree->ancestor(root, 1);
612616
ScheduleTree* seqTree;
617+
if (tree->elemAs<detail::ScheduleTreeElemExtension>()) {
618+
tree = tree->child({0});
619+
parent = tree;
620+
}
613621
if (tree->elemAs<detail::ScheduleTreeElemSequence>()) {
614622
seqTree = tree;
615623
pos = tree->numChildren();

tc/core/polyhedral/schedule_transforms.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ void insertExtensionLabelAt(
225225

226226
// Insert a zero-dimensional extension statement with the given identifier
227227
// before node "tree".
228-
// If "tree" is a sequence node or a grandchild of a sequence node,
228+
// If "tree" is a sequence node, an extension node with a sequence child,
229+
// or a grandchild of a sequence node,
229230
// then the new statement is inserted in the right position
230231
// of that sequence node.
231232
// Otherwise, a new sequence node is inserted.
@@ -236,7 +237,8 @@ void insertExtensionLabelBefore(
236237

237238
// Insert a zero-dimensional extension statement with the given identifier
238239
// after node "tree".
239-
// If "tree" is a sequence node or a grandchild of a sequence node,
240+
// If "tree" is a sequence node, an extension node with a sequence child,
241+
// or a grandchild of a sequence node,
240242
// then the new statement is inserted in the right position
241243
// of that sequence node.
242244
// Otherwise, a new sequence node is inserted.

0 commit comments

Comments
 (0)