Move ScopStmt::Domain to isl++

llvm-svn: 310207
This commit is contained in:
Tobias Grosser 2017-08-06 16:11:53 +00:00
parent cb0224ad59
commit a9b5bbac78
2 changed files with 21 additions and 23 deletions

View File

@ -1222,7 +1222,7 @@ private:
/// ///
/// A pair of statement and iteration vector (S, (5,3)) is called statement /// A pair of statement and iteration vector (S, (5,3)) is called statement
/// instance. /// instance.
isl_set *Domain; isl::set Domain;
/// The memory accesses of this statement. /// The memory accesses of this statement.
/// ///
@ -1598,7 +1598,7 @@ public:
/// Restrict the domain of the statement. /// Restrict the domain of the statement.
/// ///
/// @param NewDomain The new statement domain. /// @param NewDomain The new statement domain.
void restrictDomain(__isl_take isl_set *NewDomain); void restrictDomain(isl::set NewDomain);
/// Get the loop for a dimension. /// Get the loop for a dimension.
/// ///

View File

@ -1251,10 +1251,9 @@ __isl_give isl_map *ScopStmt::getSchedule() const {
return M; return M;
} }
void ScopStmt::restrictDomain(__isl_take isl_set *NewDomain) { void ScopStmt::restrictDomain(isl::set NewDomain) {
assert(isl_set_is_subset(NewDomain, Domain) && assert(NewDomain.is_subset(Domain) &&
"New domain is not a subset of old domain!"); "New domain is not a subset of old domain!");
isl_set_free(Domain);
Domain = NewDomain; Domain = NewDomain;
} }
@ -1318,7 +1317,7 @@ void ScopStmt::realignParams() {
isl::set Ctx = isl::manage(Parent.getContext()); isl::set Ctx = isl::manage(Parent.getContext());
InvalidDomain = InvalidDomain.gist_params(Ctx); 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. /// 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() { 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::manage(getParent()->getDomainConditions(this));
Domain = isl_set_set_tuple_id(Domain, Id); Domain = Domain.set_tuple_id(Id);
} }
void ScopStmt::collectSurroundingLoops() { void ScopStmt::collectSurroundingLoops() {
for (unsigned u = 0, e = isl_set_n_dim(Domain); u < e; u++) { for (unsigned u = 0, e = Domain.dim(isl::dim::set); u < e; u++) {
isl_id *DimId = isl_set_get_dim_id(Domain, isl_dim_set, u); isl::id DimId = Domain.get_dim_id(isl::dim::set, u);
NestLoops.push_back(static_cast<Loop *>(isl_id_get_user(DimId))); NestLoops.push_back(static_cast<Loop *>(DimId.get_user()));
isl_id_free(DimId);
} }
} }
@ -1724,12 +1722,12 @@ ScopStmt::ScopStmt(Scop &parent, BasicBlock &bb, Loop *SurroundingLoop,
ScopStmt::ScopStmt(Scop &parent, __isl_take isl_map *SourceRel, ScopStmt::ScopStmt(Scop &parent, __isl_take isl_map *SourceRel,
__isl_take isl_map *TargetRel, __isl_take isl_set *NewDomain) __isl_take isl_map *TargetRel, __isl_take isl_set *NewDomain)
: Parent(parent), InvalidDomain(nullptr), Domain(NewDomain), BB(nullptr), : Parent(parent), InvalidDomain(nullptr), Domain(isl::manage(NewDomain)),
R(nullptr), Build(nullptr) { BB(nullptr), R(nullptr), Build(nullptr) {
BaseName = getIslCompatibleName("CopyStmt_", "", BaseName = getIslCompatibleName("CopyStmt_", "",
std::to_string(parent.getCopyStmtsNum())); std::to_string(parent.getCopyStmtsNum()));
auto *Id = isl_id_alloc(getIslCtx(), getBaseName(), this); 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); TargetRel = isl_map_set_tuple_id(TargetRel, isl_dim_in, Id);
auto *Access = new MemoryAccess(this, MemoryAccess::AccessType::MUST_WRITE, auto *Access = new MemoryAccess(this, MemoryAccess::AccessType::MUST_WRITE,
isl::manage(TargetRel)); 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 { std::string ScopStmt::getScheduleStr() const {
auto *S = getSchedule(); auto *S = getSchedule();
@ -1913,17 +1911,17 @@ Loop *ScopStmt::getLoopForDimension(unsigned Dimension) const {
isl_ctx *ScopStmt::getIslCtx() const { return Parent.getIslCtx(); } 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 { __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 { __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 { void ScopStmt::printInstructions(raw_ostream &OS) const {
OS << "Instructions {\n"; OS << "Instructions {\n";
@ -4806,10 +4804,10 @@ bool Scop::restrictDomains(__isl_take isl_union_set *Domain) {
NewStmtDomain = isl_union_set_coalesce(NewStmtDomain); NewStmtDomain = isl_union_set_coalesce(NewStmtDomain);
if (isl_union_set_is_empty(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); isl_union_set_free(NewStmtDomain);
} else } else
Stmt.restrictDomain(isl_set_from_union_set(NewStmtDomain)); Stmt.restrictDomain(isl::manage(isl_set_from_union_set(NewStmtDomain)));
} }
isl_union_set_free(Domain); isl_union_set_free(Domain);
return Changed; return Changed;