From a9b5bbac789a69322ec62011bcb8e8462a097e59 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Sun, 6 Aug 2017 16:11:53 +0000 Subject: [PATCH] Move ScopStmt::Domain to isl++ llvm-svn: 310207 --- polly/include/polly/ScopInfo.h | 4 ++-- polly/lib/Analysis/ScopInfo.cpp | 40 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 0c69eef55842..7b02bdcd4774 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1222,7 +1222,7 @@ private: /// /// A pair of statement and iteration vector (S, (5,3)) is called statement /// instance. - isl_set *Domain; + isl::set Domain; /// The memory accesses of this statement. /// @@ -1598,7 +1598,7 @@ public: /// Restrict the domain of the statement. /// /// @param NewDomain The new statement domain. - void restrictDomain(__isl_take isl_set *NewDomain); + void restrictDomain(isl::set NewDomain); /// Get the loop for a dimension. /// diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index e6cbde230761..46fffc96712c 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1251,10 +1251,9 @@ __isl_give isl_map *ScopStmt::getSchedule() const { return M; } -void ScopStmt::restrictDomain(__isl_take isl_set *NewDomain) { - assert(isl_set_is_subset(NewDomain, Domain) && +void ScopStmt::restrictDomain(isl::set NewDomain) { + assert(NewDomain.is_subset(Domain) && "New domain is not a subset of old domain!"); - isl_set_free(Domain); Domain = NewDomain; } @@ -1318,7 +1317,7 @@ void ScopStmt::realignParams() { isl::set Ctx = isl::manage(Parent.getContext()); InvalidDomain = InvalidDomain.gist_params(Ctx); - Domain = isl_set_gist_params(Domain, Ctx.copy()); + Domain = Domain.gist_params(Ctx); } /// Add @p BSet to the set @p User if @p BSet is bounded. @@ -1690,17 +1689,16 @@ buildConditionSets(Scop &S, BasicBlock *BB, TerminatorInst *TI, Loop *L, } void ScopStmt::buildDomain() { - isl_id *Id = isl_id_alloc(getIslCtx(), getBaseName(), this); + isl::id Id = isl::id::alloc(getIslCtx(), getBaseName(), this); - Domain = getParent()->getDomainConditions(this); - Domain = isl_set_set_tuple_id(Domain, Id); + Domain = isl::manage(getParent()->getDomainConditions(this)); + Domain = Domain.set_tuple_id(Id); } void ScopStmt::collectSurroundingLoops() { - for (unsigned u = 0, e = isl_set_n_dim(Domain); u < e; u++) { - isl_id *DimId = isl_set_get_dim_id(Domain, isl_dim_set, u); - NestLoops.push_back(static_cast(isl_id_get_user(DimId))); - isl_id_free(DimId); + for (unsigned u = 0, e = Domain.dim(isl::dim::set); u < e; u++) { + isl::id DimId = Domain.get_dim_id(isl::dim::set, u); + NestLoops.push_back(static_cast(DimId.get_user())); } } @@ -1724,12 +1722,12 @@ ScopStmt::ScopStmt(Scop &parent, BasicBlock &bb, Loop *SurroundingLoop, ScopStmt::ScopStmt(Scop &parent, __isl_take isl_map *SourceRel, __isl_take isl_map *TargetRel, __isl_take isl_set *NewDomain) - : Parent(parent), InvalidDomain(nullptr), Domain(NewDomain), BB(nullptr), - R(nullptr), Build(nullptr) { + : Parent(parent), InvalidDomain(nullptr), Domain(isl::manage(NewDomain)), + BB(nullptr), R(nullptr), Build(nullptr) { BaseName = getIslCompatibleName("CopyStmt_", "", std::to_string(parent.getCopyStmtsNum())); auto *Id = isl_id_alloc(getIslCtx(), getBaseName(), this); - Domain = isl_set_set_tuple_id(Domain, isl_id_copy(Id)); + Domain = Domain.set_tuple_id(isl::manage(isl_id_copy(Id))); TargetRel = isl_map_set_tuple_id(TargetRel, isl_dim_in, Id); auto *Access = new MemoryAccess(this, MemoryAccess::AccessType::MUST_WRITE, isl::manage(TargetRel)); @@ -1884,7 +1882,7 @@ void ScopStmt::checkForReductions() { } } -std::string ScopStmt::getDomainStr() const { return stringFromIslObj(Domain); } +std::string ScopStmt::getDomainStr() const { return Domain.to_str(); } std::string ScopStmt::getScheduleStr() const { auto *S = getSchedule(); @@ -1913,17 +1911,17 @@ Loop *ScopStmt::getLoopForDimension(unsigned Dimension) const { isl_ctx *ScopStmt::getIslCtx() const { return Parent.getIslCtx(); } -__isl_give isl_set *ScopStmt::getDomain() const { return isl_set_copy(Domain); } +__isl_give isl_set *ScopStmt::getDomain() const { return Domain.copy(); } __isl_give isl_space *ScopStmt::getDomainSpace() const { - return isl_set_get_space(Domain); + return Domain.get_space().release(); } __isl_give isl_id *ScopStmt::getDomainId() const { - return isl_set_get_tuple_id(Domain); + return Domain.get_tuple_id().release(); } -ScopStmt::~ScopStmt() { isl_set_free(Domain); } +ScopStmt::~ScopStmt() {} void ScopStmt::printInstructions(raw_ostream &OS) const { OS << "Instructions {\n"; @@ -4806,10 +4804,10 @@ bool Scop::restrictDomains(__isl_take isl_union_set *Domain) { NewStmtDomain = isl_union_set_coalesce(NewStmtDomain); if (isl_union_set_is_empty(NewStmtDomain)) { - Stmt.restrictDomain(isl_set_empty(Stmt.getDomainSpace())); + Stmt.restrictDomain(isl::set::empty(isl::manage(Stmt.getDomainSpace()))); isl_union_set_free(NewStmtDomain); } else - Stmt.restrictDomain(isl_set_from_union_set(NewStmtDomain)); + Stmt.restrictDomain(isl::manage(isl_set_from_union_set(NewStmtDomain))); } isl_union_set_free(Domain); return Changed;