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

Commit ff810a8

Browse files
committed
ScheduleTreeSet: hide copy constructor
ScheduleTree nodes are not supposed to be manipulated by-value, only via unique pointers. Make the copy constructor of ScheduleTreeSet private, similarly to its main constructor, and provide a static member function to return copies wrapped in a unique pointer. Note that unlike the conventional copy constructor, this static function takes a pointer to the tree rather than a reference. This keeps the API consistent as all other functions manipulate with pointers to the tree nodes rather than references.
1 parent 6d09b28 commit ff810a8

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

tc/core/polyhedral/schedule_tree.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static std::unique_ptr<ScheduleTree> makeElem(const ScheduleTree& st) {
144144
ELEM_MAKE_CASE_CSTR(ScheduleTreeFilter)
145145
ELEM_MAKE_CASE_CSTR(ScheduleTreeMapping)
146146
ELEM_MAKE_CASE_CSTR(ScheduleTreeSequence)
147-
ELEM_MAKE_CASE(ScheduleTreeSet)
147+
ELEM_MAKE_CASE_CSTR(ScheduleTreeSet)
148148
ELEM_MAKE_CASE(ScheduleTreeThreadSpecificMarker)
149149

150150
#undef ELEM_MAKE_CASE_CSTR

tc/core/polyhedral/schedule_tree_elem.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ std::unique_ptr<ScheduleTreeSet> ScheduleTreeSet::make(
175175
return res;
176176
}
177177

178+
std::unique_ptr<ScheduleTreeSet> ScheduleTreeSet::make(
179+
const ScheduleTreeSet* tree,
180+
std::vector<ScheduleTreeUPtr>&& children) {
181+
auto res = std::unique_ptr<ScheduleTreeSet>(new ScheduleTreeSet(*tree));
182+
res->appendChildren(std::move(children));
183+
return res;
184+
}
185+
178186
std::unique_ptr<ScheduleTreeBand> ScheduleTreeBand::make(
179187
isl::multi_union_pw_aff mupa,
180188
bool permutable,

tc/core/polyhedral/schedule_tree_elem.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ struct ScheduleTreeSet : public ScheduleTree {
238238

239239
private:
240240
explicit ScheduleTreeSet(isl::ctx ctx) : ScheduleTree(ctx, {}, NodeType) {}
241+
ScheduleTreeSet(const ScheduleTreeSet& eb) : ScheduleTree(eb) {}
241242

242243
public:
243-
ScheduleTreeSet(const ScheduleTreeSet& eb) : ScheduleTree(eb) {}
244244
virtual ~ScheduleTreeSet() override {}
245245

246246
bool operator==(const ScheduleTreeSet& other) const;
@@ -251,6 +251,9 @@ struct ScheduleTreeSet : public ScheduleTree {
251251
static std::unique_ptr<ScheduleTreeSet> make(
252252
isl::ctx ctx,
253253
std::vector<ScheduleTreeUPtr>&& children = {});
254+
static std::unique_ptr<ScheduleTreeSet> make(
255+
const ScheduleTreeSet* tree,
256+
std::vector<ScheduleTreeUPtr>&& children = {});
254257

255258
virtual std::ostream& write(std::ostream& os) const override;
256259
};

0 commit comments

Comments
 (0)