Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -19,6 +19,7 @@ #define POLLY_SCOP_INFO_H #include "polly/ScopDetection.h" +#include "polly/Support/ISLConversion.h" #include "polly/Support/SCEVAffinator.h" #include "llvm/ADT/MapVector.h" @@ -315,7 +316,7 @@ // Scalars do not have array dimensions and the first dimension of // a (possibly multi-dimensional) array also does not carry any size // information, in case the array is not newly created. - __isl_give isl_pw_aff *getDimensionSizePw(unsigned Dim) const { + isl_conv::pw_aff getDimensionSizePw(unsigned Dim) const { assert(Dim < getNumberOfDimensions() && "Invalid dimension"); return isl_pw_aff_copy(DimensionSizesPw[Dim]); } @@ -332,7 +333,7 @@ std::string getName() const; /// Return the isl id for the base pointer. - __isl_give isl_id *getBasePtrId() const; + isl_conv::id getBasePtrId() const; /// Return what kind of memory this represents. MemoryKind getKind() const { return Kind; } @@ -382,7 +383,7 @@ static const ScopArrayInfo *getFromId(__isl_take isl_id *Id); /// Get the space of this array access. - __isl_give isl_space *getSpace() const; + isl_conv::space getSpace() const; /// If the array is read only bool isReadOnly(); @@ -647,7 +648,7 @@ AssertingVH FAD; // @} - __isl_give isl_basic_map *createBasicAccessMap(ScopStmt *Statement); + isl_conv::basic_map createBasicAccessMap(ScopStmt *Statement); void assumeNoOutOfBound(); @@ -657,13 +658,13 @@ void computeBoundsOnAccessRelation(unsigned ElementSize); /// Get the original access function as read from IR. - __isl_give isl_map *getOriginalAccessRelation() const; + isl_conv::map getOriginalAccessRelation() const; /// Return the space in which the access relation lives in. - __isl_give isl_space *getOriginalAccessRelationSpace() const; + isl_conv::space getOriginalAccessRelationSpace() const; /// Get the new access function imported or set by a pass - __isl_give isl_map *getNewAccessRelation() const; + isl_conv::map getNewAccessRelation() const; /// Fold the memory access to consider parametric offsets /// @@ -810,15 +811,13 @@ /// As 2) is by construction "newer" than 1) we return the new access /// relation if present. /// - __isl_give isl_map *getLatestAccessRelation() const { + isl_conv::map getLatestAccessRelation() const { return hasNewAccessRelation() ? getNewAccessRelation() : getOriginalAccessRelation(); } /// Old name of getLatestAccessRelation(). - __isl_give isl_map *getAccessRelation() const { - return getLatestAccessRelation(); - } + isl_conv::map getAccessRelation() const { return getLatestAccessRelation(); } /// Get an isl map describing the memory address accessed. /// @@ -833,10 +832,10 @@ /// will return the address function { S[i] -> A[4i] }. /// /// @returns The address function for this memory access. - __isl_give isl_map *getAddressFunction() const; + isl_conv::map getAddressFunction() const; /// Return the access relation after the schedule was applied. - __isl_give isl_pw_multi_aff * + isl_conv::pw_multi_aff applyScheduleToAccessRelation(__isl_take isl_union_map *Schedule) const; /// Get an isl string representing the access function read from IR. @@ -858,14 +857,14 @@ Value *getOriginalBaseAddr() const { return BaseAddr; } /// Get the detection-time base array isl_id for this access. - __isl_give isl_id *getOriginalArrayId() const; + isl_conv::id getOriginalArrayId() const; /// Get the base array isl_id for this access, modifiable through /// setNewAccessRelation(). - __isl_give isl_id *getLatestArrayId() const; + isl_conv::id getLatestArrayId() const; /// Old name of getOriginalArrayId(). - __isl_give isl_id *getArrayId() const { return getOriginalArrayId(); } + isl_conv::id getArrayId() const { return getOriginalArrayId(); } /// Get the detection-time ScopArrayInfo object for the base address. const ScopArrayInfo *getOriginalScopArrayInfo() const; @@ -918,22 +917,20 @@ /// Compute the isl representation for the SCEV @p E wrt. this access. /// /// Note that this function will also adjust the invalid context accordingly. - __isl_give isl_pw_aff *getPwAff(const SCEV *E); + isl_conv::pw_aff getPwAff(const SCEV *E); /// Get the invalid domain for this access. - __isl_give isl_set *getInvalidDomain() const { - return isl_set_copy(InvalidDomain); - } + isl_conv::set getInvalidDomain() const { return isl_set_copy(InvalidDomain); } /// Get the invalid context for this access. - __isl_give isl_set *getInvalidContext() const { + isl_conv::set getInvalidContext() const { return isl_set_params(getInvalidDomain()); } /// Get the stride of this memory access in the specified Schedule. Schedule /// is a map from the statement to a schedule where the innermost dimension is /// the dimension of the innermost loop containing the statement. - __isl_give isl_set *getStride(__isl_take const isl_map *Schedule) const; + isl_conv::set getStride(__isl_take const isl_map *Schedule) const; /// Get the FortranArrayDescriptor corresponding to this memory access if /// it exists, and nullptr otherwise. @@ -1101,7 +1098,7 @@ /// /// This identifier is unique for all accesses that belong to the same scop /// statement. - __isl_give isl_id *getId() const; + isl_conv::id getId() const; /// Print the MemoryAccess. /// @@ -1322,17 +1319,17 @@ /// Get the iteration domain of this ScopStmt. /// /// @return The iteration domain of this ScopStmt. - __isl_give isl_set *getDomain() const; + isl_conv::set getDomain() const; /// Get the space of the iteration domain /// /// @return The space of the iteration domain - __isl_give isl_space *getDomainSpace() const; + isl_conv::space getDomainSpace() const; /// Get the id of the iteration domain space /// /// @return The id of the iteration domain space - __isl_give isl_id *getDomainId() const; + isl_conv::id getDomainId() const; /// Get an isl string representing this domain. std::string getDomainStr() const; @@ -1341,7 +1338,7 @@ /// /// @return The schedule function of this ScopStmt, if it does not contain /// extension nodes, and nullptr, otherwise. - __isl_give isl_map *getSchedule() const; + isl_conv::map getSchedule() const; /// Get an isl string representing this schedule. /// @@ -1350,12 +1347,10 @@ std::string getScheduleStr() const; /// Get the invalid domain for this statement. - __isl_give isl_set *getInvalidDomain() const { - return isl_set_copy(InvalidDomain); - } + isl_conv::set getInvalidDomain() const { return isl_set_copy(InvalidDomain); } /// Get the invalid context for this statement. - __isl_give isl_set *getInvalidContext() const { + isl_conv::set getInvalidContext() const { return isl_set_params(getInvalidDomain()); } @@ -1946,9 +1941,10 @@ /// @param LI The LoopInfo for the current function. /// /// @returns The domain under which @p BB is executed. - __isl_give isl_set * - getPredecessorDomainConstraints(BasicBlock *BB, __isl_keep isl_set *Domain, - DominatorTree &DT, LoopInfo &LI); + isl_conv::set getPredecessorDomainConstraints(BasicBlock *BB, + __isl_keep isl_set *Domain, + DominatorTree &DT, + LoopInfo &LI); /// Add loop carried constraints to the header block of the loop @p L. /// @@ -2021,7 +2017,7 @@ DenseMap &InvalidDomainMap); /// Add parameter constraints to @p C that imply a non-empty domain. - __isl_give isl_set *addNonEmptyDomainConstraints(__isl_take isl_set *C) const; + isl_conv::set addNonEmptyDomainConstraints(__isl_take isl_set *C) const; /// Return the access for the base ptr of @p MA if any. MemoryAccess *lookupBasePtrAccess(MemoryAccess *MA); @@ -2315,7 +2311,7 @@ /// of a given type. /// /// @returns The set of memory accesses in the scop that match the predicate. - __isl_give isl_union_map * + isl_conv::union_map getAccessesOfType(std::function Predicate); /// @name Helper functions for printing the Scop. @@ -2413,7 +2409,7 @@ /// @param Parameter A SCEV that was recognized as a Parameter. /// /// @return The corresponding isl_id or NULL otherwise. - __isl_give isl_id *getIdForParam(const SCEV *Parameter); + isl_conv::id getIdForParam(const SCEV *Parameter); /// Get the maximum region of this static control part. /// @@ -2499,13 +2495,13 @@ /// Get the constraint on parameter of this Scop. /// /// @return The constraint on parameter of this Scop. - __isl_give isl_set *getContext() const; - __isl_give isl_space *getParamSpace() const; + isl_conv::set getContext() const; + isl_conv::space getParamSpace() const; /// Get the assumed context for this Scop. /// /// @return The assumed context of this Scop. - __isl_give isl_set *getAssumedContext() const; + isl_conv::set getAssumedContext() const; /// Return true if the optimized SCoP can be executed. /// @@ -2599,7 +2595,7 @@ /// Get the invalid context for this Scop. /// /// @return The invalid context of this Scop. - __isl_give isl_set *getInvalidContext() const; + isl_conv::set getInvalidContext() const; /// Return true if and only if the InvalidContext is trivial (=empty). bool hasTrivialInvalidContext() const { @@ -2852,44 +2848,44 @@ /// /// This function is like @see Scop::getPwAff() but strips away the invalid /// domain part associated with the piecewise affine function. - __isl_give isl_pw_aff *getPwAffOnly(const SCEV *E, BasicBlock *BB = nullptr); + isl_conv::pw_aff getPwAffOnly(const SCEV *E, BasicBlock *BB = nullptr); /// Return the domain of @p Stmt. /// /// @param Stmt The statement for which the conditions should be returned. - __isl_give isl_set *getDomainConditions(const ScopStmt *Stmt) const; + isl_conv::set getDomainConditions(const ScopStmt *Stmt) const; /// Return the domain of @p BB. /// /// @param BB The block for which the conditions should be returned. - __isl_give isl_set *getDomainConditions(BasicBlock *BB) const; + isl_conv::set getDomainConditions(BasicBlock *BB) const; /// Get a union set containing the iteration domains of all statements. - __isl_give isl_union_set *getDomains() const; + isl_conv::union_set getDomains() const; /// Get a union map of all may-writes performed in the SCoP. - __isl_give isl_union_map *getMayWrites(); + isl_conv::union_map getMayWrites(); /// Get a union map of all must-writes performed in the SCoP. - __isl_give isl_union_map *getMustWrites(); + isl_conv::union_map getMustWrites(); /// Get a union map of all writes performed in the SCoP. - __isl_give isl_union_map *getWrites(); + isl_conv::union_map getWrites(); /// Get a union map of all reads performed in the SCoP. - __isl_give isl_union_map *getReads(); + isl_conv::union_map getReads(); /// Get a union map of all memory accesses performed in the SCoP. - __isl_give isl_union_map *getAccesses(); + isl_conv::union_map getAccesses(); /// Get the schedule of all the statements in the SCoP. /// /// @return The schedule of all the statements in the SCoP, if the schedule of /// the Scop does not contain extension nodes, and nullptr, otherwise. - __isl_give isl_union_map *getSchedule() const; + isl_conv::union_map getSchedule() const; /// Get a schedule tree describing the schedule of all statements. - __isl_give isl_schedule *getScheduleTree() const; + isl_conv::schedule getScheduleTree() const; /// Update the current schedule /// Index: include/polly/Support/ISLConversion.h =================================================================== --- /dev/null +++ include/polly/Support/ISLConversion.h @@ -0,0 +1,58 @@ +//===------ ISLConversion.h -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This tool provides islpp classes that automatically convert to either the +// native isl type or the corresponding islpp type. +// +//===----------------------------------------------------------------------===// + +#ifndef POLLY_ISL_CONVERSION_H +#define POLLY_ISL_CONVERSION_H + +#include "isl-noexceptions.h" + +namespace polly { +namespace isl_conv { + +template +class IslConversion : public ISL_CLASS { + ISL_CLASS Obj; +public: + IslConversion(ISL_TYPE *Ptr) : ISL_CLASS(isl::manage(Ptr)) {} + IslConversion(ISL_CLASS Obj) : ISL_CLASS(Obj) {} + operator ISL_TYPE*() { + return ISL_CLASS::copy(); + } + + operator ISL_CLASS() { + return this; + } +}; + +#define CONF(TYPE) typedef IslConversion TYPE; + +CONF(basic_set); +CONF(set); +CONF(union_set); + +CONF(basic_map); +CONF(map); +CONF(union_map); + +CONF(id); +CONF(space); +CONF(schedule); + +CONF(pw_aff); +CONF(pw_multi_aff); + +} +} + +#endif /* POLLY_ISL_CONVERSIONS_H */ Index: lib/Analysis/DependenceInfo.cpp =================================================================== --- lib/Analysis/DependenceInfo.cpp +++ lib/Analysis/DependenceInfo.cpp @@ -156,7 +156,7 @@ } else { accdom = tag(accdom, MA, Level); if (Level > Dependences::AL_Statement) { - auto *StmtScheduleMap = Stmt.getSchedule(); + isl_map *StmtScheduleMap = Stmt.getSchedule(); assert(StmtScheduleMap && "Schedules that contain extension nodes require special " "handling."); Index: lib/Analysis/PolyhedralInfo.cpp =================================================================== --- lib/Analysis/PolyhedralInfo.cpp +++ lib/Analysis/PolyhedralInfo.cpp @@ -131,7 +131,7 @@ unsigned int MaxDim = SS.getNumIterators(); DEBUG(dbgs() << "Maximum depth of Stmt:\t" << MaxDim << "\n"); - auto *ScheduleMap = SS.getSchedule(); + isl_map *ScheduleMap = SS.getSchedule(); assert( ScheduleMap && "Schedules that contain extension nodes require special handling."); Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -282,7 +282,7 @@ const_cast(BasePtrOriginSAI)->addDerivedSAI(this); } -__isl_give isl_space *ScopArrayInfo::getSpace() const { +isl_conv::space ScopArrayInfo::getSpace() const { auto *Space = isl_space_set_alloc(isl_id_get_ctx(Id), 0, getNumberOfDimensions()); Space = isl_space_set_tuple_id(Space, isl_dim_set, isl_id_copy(Id)); @@ -403,9 +403,7 @@ return DL.getTypeAllocSize(ElementType); } -__isl_give isl_id *ScopArrayInfo::getBasePtrId() const { - return isl_id_copy(Id); -} +isl_conv::id ScopArrayInfo::getBasePtrId() const { return isl_id_copy(Id); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void ScopArrayInfo::dump() const { print(errs()); } @@ -427,7 +425,7 @@ OS << "["; if (SizeAsPwAff) { - auto *Size = getDimensionSizePw(u); + isl_pw_aff *Size = getDimensionSizePw(u); OS << " " << Size << " "; isl_pw_aff_free(Size); } else { @@ -672,21 +670,21 @@ return SAI; } -__isl_give isl_id *MemoryAccess::getOriginalArrayId() const { +isl_conv::id MemoryAccess::getOriginalArrayId() const { return isl_map_get_tuple_id(AccessRelation, isl_dim_out); } -__isl_give isl_id *MemoryAccess::getLatestArrayId() const { +isl_conv::id MemoryAccess::getLatestArrayId() const { if (!hasNewAccessRelation()) return getOriginalArrayId(); return isl_map_get_tuple_id(NewAccessRelation, isl_dim_out); } -__isl_give isl_map *MemoryAccess::getAddressFunction() const { +isl_conv::map MemoryAccess::getAddressFunction() const { return isl_map_lexmin(getAccessRelation()); } -__isl_give isl_pw_multi_aff *MemoryAccess::applyScheduleToAccessRelation( +isl_conv::pw_multi_aff MemoryAccess::applyScheduleToAccessRelation( __isl_take isl_union_map *USchedule) const { isl_map *Schedule, *ScheduledAccRel; isl_union_set *UDomain; @@ -698,7 +696,7 @@ return isl_pw_multi_aff_from_map(ScheduledAccRel); } -__isl_give isl_map *MemoryAccess::getOriginalAccessRelation() const { +isl_conv::map MemoryAccess::getOriginalAccessRelation() const { return isl_map_copy(AccessRelation); } @@ -706,11 +704,11 @@ return stringFromIslObj(AccessRelation); } -__isl_give isl_space *MemoryAccess::getOriginalAccessRelationSpace() const { +isl_conv::space MemoryAccess::getOriginalAccessRelationSpace() const { return isl_map_get_space(AccessRelation); } -__isl_give isl_map *MemoryAccess::getNewAccessRelation() const { +isl_conv::map MemoryAccess::getNewAccessRelation() const { return isl_map_copy(NewAccessRelation); } @@ -722,8 +720,7 @@ return isl::manage(getAccessRelation()).to_str(); } -__isl_give isl_basic_map * -MemoryAccess::createBasicAccessMap(ScopStmt *Statement) { +isl_conv::basic_map MemoryAccess::createBasicAccessMap(ScopStmt *Statement) { isl_space *Space = isl_space_set_alloc(Statement->getIslCtx(), 0, 1); Space = isl_space_align_params(Space, Statement->getDomainSpace()); @@ -774,7 +771,7 @@ } Outside = Outside.apply(give(getAccessRelation()).reverse()); - Outside = Outside.intersect(give(Statement->getDomain())); + Outside = Outside.intersect(Statement->getDomain()); Outside = Outside.params(); // Remove divs to avoid the construction of overly complicated assumptions. @@ -786,8 +783,9 @@ const auto &Loc = getAccessInstruction() ? getAccessInstruction()->getDebugLoc() : DebugLoc(); - if (!PollyPreciseInbounds) - Outside = Outside.gist_params(give(Statement->getDomain()).params()); + if (!PollyPreciseInbounds) { + Outside = Outside.gist_params(Statement->getDomain().params()); + } Statement->getParent()->recordAssumption(INBOUNDS, Outside.release(), Loc, AS_ASSUMPTION); } @@ -918,8 +916,7 @@ NewAccessRelation = NewAccessRelation.set_tuple_id( isl::dim::in, Space.get_tuple_id(isl::dim::set)); NewAccessRelation = NewAccessRelation.set_tuple_id(isl::dim::out, BaseAddrId); - NewAccessRelation = - NewAccessRelation.gist_domain(give(Statement->getDomain())); + NewAccessRelation = NewAccessRelation.gist_domain(Statement->getDomain()); // Access dimension folding might in certain cases increase the number of // disjuncts in the memory access, which can possibly complicate the generated @@ -967,7 +964,7 @@ // Initialize the invalid domain which describes all iterations for which the // access relation is not modeled correctly. - auto *StmtInvalidDomain = getStatement()->getInvalidDomain(); + isl_set *StmtInvalidDomain = getStatement()->getInvalidDomain(); InvalidDomain = isl_set_empty(isl_set_get_space(StmtInvalidDomain)); isl_set_free(StmtInvalidDomain); @@ -1053,7 +1050,7 @@ } void MemoryAccess::realignParams() { - auto *Ctx = Statement->getParent()->getContext(); + isl_set *Ctx = Statement->getParent()->getContext(); InvalidDomain = isl_set_gist_params(InvalidDomain, isl_set_copy(Ctx)); AccessRelation = isl_map_gist_params(AccessRelation, Ctx); } @@ -1062,7 +1059,7 @@ return MemoryAccess::getReductionOperatorStr(getReductionType()); } -__isl_give isl_id *MemoryAccess::getId() const { return isl_id_copy(Id); } +isl_conv::id MemoryAccess::getId() const { return isl_id_copy(Id); } raw_ostream &polly::operator<<(raw_ostream &OS, MemoryAccess::ReductionType RT) { @@ -1105,7 +1102,7 @@ LLVM_DUMP_METHOD void MemoryAccess::dump() const { print(errs()); } #endif -__isl_give isl_pw_aff *MemoryAccess::getPwAff(const SCEV *E) { +isl_conv::pw_aff MemoryAccess::getPwAff(const SCEV *E) { auto *Stmt = getStatement(); PWACtx PWAC = Stmt->getParent()->getPwAff(E, Stmt->getEntryBlock()); isl_set *StmtDom = isl_set_reset_tuple_id(getStatement()->getDomain()); @@ -1147,7 +1144,7 @@ return Map; } -__isl_give isl_set * +isl_conv::set MemoryAccess::getStride(__isl_take const isl_map *Schedule) const { isl_map *S = const_cast(Schedule); isl_map *AccessRelation = getAccessRelation(); @@ -1205,7 +1202,7 @@ // Check domain space compatibility. auto *NewSpace = isl_map_get_space(NewAccess); auto *NewDomainSpace = isl_space_domain(isl_space_copy(NewSpace)); - auto *OriginalDomainSpace = getStatement()->getDomainSpace(); + isl_space *OriginalDomainSpace = getStatement()->getDomainSpace(); assert(isl_space_has_equal_tuples(OriginalDomainSpace, NewDomainSpace)); isl_space_free(NewDomainSpace); isl_space_free(OriginalDomainSpace); @@ -1214,7 +1211,7 @@ // subdomain only. if (isRead()) { // Check whether there is an access for every statement instance. - auto *StmtDomain = getStatement()->getDomain(); + isl_set *StmtDomain = getStatement()->getDomain(); StmtDomain = isl_set_intersect_params( StmtDomain, getStatement()->getParent()->getContext()); auto *NewDomain = isl_map_domain(isl_map_copy(NewAccess)); @@ -1255,7 +1252,7 @@ } bool MemoryAccess::isLatestPartialAccess() const { - isl::set StmtDom = give(getStatement()->getDomain()); + isl::set StmtDom = getStatement()->getDomain(); isl::set AccDom = give(isl_map_domain(getLatestAccessRelation())); return isl_set_is_subset(StmtDom.keep(), AccDom.keep()) == isl_bool_false; @@ -1263,14 +1260,14 @@ //===----------------------------------------------------------------------===// -__isl_give isl_map *ScopStmt::getSchedule() const { +isl_conv::map ScopStmt::getSchedule() const { isl_set *Domain = getDomain(); if (isl_set_is_empty(Domain)) { isl_set_free(Domain); return isl_map_from_aff( isl_aff_zero_on_domain(isl_local_space_from_space(getDomainSpace()))); } - auto *Schedule = getParent()->getSchedule(); + isl_union_map *Schedule = getParent()->getSchedule(); if (!Schedule) { isl_set_free(Domain); return nullptr; @@ -1355,7 +1352,7 @@ for (MemoryAccess *MA : *this) MA->realignParams(); - auto *Ctx = Parent.getContext(); + isl_set *Ctx = Parent.getContext(); InvalidDomain = isl_set_gist_params(InvalidDomain, isl_set_copy(Ctx)); Domain = isl_set_gist_params(Domain, Ctx); } @@ -1485,10 +1482,9 @@ /// /// Note that this function will also adjust the invalid context accordingly. -__isl_give isl_pw_aff * -getPwAff(Scop &S, BasicBlock *BB, - DenseMap &InvalidDomainMap, const SCEV *E, - bool NonNegative = false) { +isl_conv::pw_aff getPwAff(Scop &S, BasicBlock *BB, + DenseMap &InvalidDomainMap, + const SCEV *E, bool NonNegative = false) { PWACtx PWAC = S.getPwAff(E, BB, NonNegative); InvalidDomainMap[BB] = InvalidDomainMap[BB].unite(isl::manage(PWAC.second)); return PWAC.first; @@ -1925,7 +1921,7 @@ std::string ScopStmt::getDomainStr() const { return stringFromIslObj(Domain); } std::string ScopStmt::getScheduleStr() const { - auto *S = getSchedule(); + isl_map *S = getSchedule(); if (!S) return ""; auto Str = stringFromIslObj(S); @@ -1954,13 +1950,15 @@ isl_ctx *ScopStmt::getIslCtx() const { return Parent.getIslCtx(); } -__isl_give isl_set *ScopStmt::getDomain() const { return isl_set_copy(Domain); } +isl_conv::set ScopStmt::getDomain() const { + return isl::manage(isl_set_copy(Domain)); +} -__isl_give isl_space *ScopStmt::getDomainSpace() const { +isl_conv::space ScopStmt::getDomainSpace() const { return isl_set_get_space(Domain); } -__isl_give isl_id *ScopStmt::getDomainId() const { +isl_conv::id ScopStmt::getDomainId() const { return isl_set_get_tuple_id(Domain); } @@ -2229,14 +2227,13 @@ } } -__isl_give isl_id *Scop::getIdForParam(const SCEV *Parameter) { +isl_conv::id Scop::getIdForParam(const SCEV *Parameter) { // Normalize the SCEV to get the representing element for an invariant load. Parameter = getRepresentingInvariantLoadSCEV(Parameter); return isl_id_copy(ParameterIds.lookup(Parameter)); } -__isl_give isl_set * -Scop::addNonEmptyDomainConstraints(__isl_take isl_set *C) const { +isl_conv::set Scop::addNonEmptyDomainConstraints(__isl_take isl_set *C) const { isl_set *DomainContext = isl_union_set_params(getDomains()); return isl_set_intersect_params(C, DomainContext); } @@ -2280,7 +2277,8 @@ SmallVector ConditionSets; auto *TI = InScop ? CI->getParent()->getTerminator() : nullptr; auto &Stmt = InScop ? *getStmtFor(CI->getParent()) : *Stmts.begin(); - auto *Dom = InScop ? getDomainConditions(&Stmt) : isl_set_copy(Context); + isl_set *Dom = + InScop ? (isl_set *)getDomainConditions(&Stmt) : isl_set_copy(Context); bool Valid = buildConditionSets(*this, Stmt.getEntryBlock(), Val, TI, L, Dom, InvalidDomainMap, ConditionSets); isl_set_free(Dom); @@ -2725,11 +2723,11 @@ return isl_set_set_dim_id(Domain, isl_dim_set, Dim, DimId); } -__isl_give isl_set *Scop::getDomainConditions(const ScopStmt *Stmt) const { +isl_conv::set Scop::getDomainConditions(const ScopStmt *Stmt) const { return getDomainConditions(Stmt->getEntryBlock()); } -__isl_give isl_set *Scop::getDomainConditions(BasicBlock *BB) const { +isl_conv::set Scop::getDomainConditions(BasicBlock *BB) const { auto DIt = DomainMap.find(BB); if (DIt != DomainMap.end()) return DIt->getSecond().copy(); @@ -3095,10 +3093,10 @@ return true; } -__isl_give isl_set * -Scop::getPredecessorDomainConstraints(BasicBlock *BB, - __isl_keep isl_set *Domain, - DominatorTree &DT, LoopInfo &LI) { +isl_conv::set Scop::getPredecessorDomainConstraints(BasicBlock *BB, + __isl_keep isl_set *Domain, + DominatorTree &DT, + LoopInfo &LI) { // If @p BB is the ScopEntry we are done if (R.getEntry() == BB) return isl_set_universe(isl_set_get_space(Domain)); @@ -3141,7 +3139,7 @@ PropagatedRegions.insert(PredR); } - auto *PredBBDom = getDomainConditions(PredBB); + isl_set *PredBBDom = getDomainConditions(PredBB); Loop *PredBBLoop = getFirstNonBoxedLoopFor(PredBB, LI, getBoxedLoops()); PredBBDom = adjustDomainDimensions(*this, PredBBDom, PredBBLoop, BBLoop); @@ -3919,7 +3917,7 @@ if (InvMAs.empty()) return; - auto *StmtInvalidCtx = Stmt.getInvalidContext(); + isl_set *StmtInvalidCtx = Stmt.getInvalidContext(); bool StmtInvalidCtxIsEmpty = isl_set_is_empty(StmtInvalidCtx); // Get the context under which the statement is executed but remove the error @@ -3973,7 +3971,7 @@ Type *Ty = LInst->getType(); const SCEV *PointerSCEV = SE->getSCEV(LInst->getPointerOperand()); - auto *MAInvalidCtx = MA->getInvalidContext(); + isl_set *MAInvalidCtx = MA->getInvalidContext(); bool NonHoistableCtxIsEmpty = isl_set_is_empty(NHCtx); bool MAInvalidCtxIsEmpty = isl_set_is_empty(MAInvalidCtx); @@ -4103,7 +4101,7 @@ if (AccessRelation.involves_dims(isl::dim::in, 0, Stmt.getNumIterators())) return nullptr; - AccessRelation = AccessRelation.intersect_domain(give(Stmt.getDomain())); + AccessRelation = AccessRelation.intersect_domain(Stmt.getDomain()); isl::set SafeToLoad; auto &DL = getFunction().getParent()->getDataLayout(); @@ -4327,12 +4325,12 @@ return std::make_pair(EntryName, ExitName); } -__isl_give isl_set *Scop::getContext() const { return isl_set_copy(Context); } -__isl_give isl_space *Scop::getParamSpace() const { +isl_conv::set Scop::getContext() const { return isl_set_copy(Context); } +isl_conv::space Scop::getParamSpace() const { return isl_set_get_space(Context); } -__isl_give isl_set *Scop::getAssumedContext() const { +isl_conv::set Scop::getAssumedContext() const { assert(AssumedContext && "Assumed context not yet built"); return isl_set_copy(AssumedContext); } @@ -4366,8 +4364,8 @@ } bool Scop::hasFeasibleRuntimeContext() const { - auto *PositiveContext = getAssumedContext(); - auto *NegativeContext = getInvalidContext(); + isl_set *PositiveContext = getAssumedContext(); + isl_set *NegativeContext = getInvalidContext(); PositiveContext = addNonEmptyDomainConstraints(PositiveContext); bool IsFeasible = !(isl_set_is_empty(PositiveContext) || isl_set_is_subset(PositiveContext, NegativeContext)); @@ -4558,7 +4556,7 @@ addAssumption(Kind, isl_set_empty(getParamSpace()), Loc, AS_ASSUMPTION, BB); } -__isl_give isl_set *Scop::getInvalidContext() const { +isl_conv::set Scop::getInvalidContext() const { return isl_set_copy(InvalidContext); } @@ -4695,7 +4693,7 @@ return Affinator.getPwAff(SE->getZero(E->getType()), BB); } -__isl_give isl_union_set *Scop::getDomains() const { +isl_conv::union_set Scop::getDomains() const { isl_space *EmptySpace = isl_space_params_alloc(getIslCtx(), 0); isl_union_set *Domain = isl_union_set_empty(EmptySpace); @@ -4705,13 +4703,13 @@ return Domain; } -__isl_give isl_pw_aff *Scop::getPwAffOnly(const SCEV *E, BasicBlock *BB) { +isl_conv::pw_aff Scop::getPwAffOnly(const SCEV *E, BasicBlock *BB) { PWACtx PWAC = getPwAff(E, BB); isl_set_free(PWAC.second); return PWAC.first; } -__isl_give isl_union_map * +isl_conv::union_map Scop::getAccessesOfType(std::function Predicate) { isl_union_map *Accesses = isl_union_map_empty(getParamSpace()); @@ -4729,23 +4727,23 @@ return isl_union_map_coalesce(Accesses); } -__isl_give isl_union_map *Scop::getMustWrites() { +isl_conv::union_map Scop::getMustWrites() { return getAccessesOfType([](MemoryAccess &MA) { return MA.isMustWrite(); }); } -__isl_give isl_union_map *Scop::getMayWrites() { +isl_conv::union_map Scop::getMayWrites() { return getAccessesOfType([](MemoryAccess &MA) { return MA.isMayWrite(); }); } -__isl_give isl_union_map *Scop::getWrites() { +isl_conv::union_map Scop::getWrites() { return getAccessesOfType([](MemoryAccess &MA) { return MA.isWrite(); }); } -__isl_give isl_union_map *Scop::getReads() { +isl_conv::union_map Scop::getReads() { return getAccessesOfType([](MemoryAccess &MA) { return MA.isRead(); }); } -__isl_give isl_union_map *Scop::getAccesses() { +isl_conv::union_map Scop::getAccesses() { return getAccessesOfType([](MemoryAccess &MA) { return true; }); } @@ -4764,8 +4762,8 @@ nullptr) == isl_stat_error; } -__isl_give isl_union_map *Scop::getSchedule() const { - auto *Tree = getScheduleTree(); +isl_conv::union_map Scop::getSchedule() const { + isl_schedule *Tree = getScheduleTree(); if (containsExtensionNode(Tree)) { isl_schedule_free(Tree); return nullptr; @@ -4775,7 +4773,7 @@ return S; } -__isl_give isl_schedule *Scop::getScheduleTree() const { +isl_conv::schedule Scop::getScheduleTree() const { return isl_schedule_intersect_domain(isl_schedule_copy(Schedule), getDomains()); } Index: lib/CodeGen/BlockGenerators.cpp =================================================================== --- lib/CodeGen/BlockGenerators.cpp +++ lib/CodeGen/BlockGenerators.cpp @@ -544,7 +544,7 @@ continue; #ifndef NDEBUG - auto *StmtDom = Stmt.getDomain(); + isl_set *StmtDom = Stmt.getDomain(); auto *AccDom = isl_map_domain(MA->getAccessRelation()); assert(isl_set_is_subset(StmtDom, AccDom) && "Scalar must be loaded in all statement instances"); @@ -566,7 +566,7 @@ Value *BlockGenerator::buildContainsCondition(ScopStmt &Stmt, const isl::set &Subdomain) { isl::ast_build AstBuild = give(isl_ast_build_copy(Stmt.getAstBuild())); - isl::set Domain = give(Stmt.getDomain()); + isl::set Domain = Stmt.getDomain(); isl::union_map USchedule = AstBuild.get_schedule(); USchedule = USchedule.intersect_domain(Domain); @@ -590,7 +590,7 @@ void BlockGenerator::generateConditionalExecution( ScopStmt &Stmt, const isl::set &Subdomain, StringRef Subject, const std::function &GenThenFunc) { - isl::set StmtDom = give(Stmt.getDomain()); + isl::set StmtDom = Stmt.getDomain(); // Don't call GenThenFunc if it is never executed. An ast index expression // might not be defined in this case. Index: lib/CodeGen/IslAst.cpp =================================================================== --- lib/CodeGen/IslAst.cpp +++ lib/CodeGen/IslAst.cpp @@ -410,7 +410,7 @@ // We can not perform the dependence analysis and, consequently, // the parallel code generation in case the schedule tree contains // extension nodes. - auto *ScheduleTree = S.getScheduleTree(); + isl_schedule *ScheduleTree = S.getScheduleTree(); PerformParallelTest = PerformParallelTest && !S.containsExtensionNode(ScheduleTree); isl_schedule_free(ScheduleTree); @@ -651,7 +651,7 @@ P = isl_ast_node_print(RootNode, P, Options); AstStr = isl_printer_get_str(P); - auto *Schedule = S.getScheduleTree(); + isl_schedule *Schedule = S.getScheduleTree(); DEBUG({ dbgs() << S.getContextStr() << "\n"; Index: lib/CodeGen/IslNodeBuilder.cpp =================================================================== --- lib/CodeGen/IslNodeBuilder.cpp +++ lib/CodeGen/IslNodeBuilder.cpp @@ -803,7 +803,7 @@ #ifndef NDEBUG if (MA->isRead()) { - auto Dom = Stmt->getDomain(); + isl_set *Dom = Stmt->getDomain(); auto SchedDom = isl_set_from_union_set( isl_union_map_domain(isl_union_map_copy(Schedule))); auto AccDom = isl_map_domain(MA->getAccessRelation()); @@ -820,7 +820,7 @@ } #endif - auto PWAccRel = MA->applyScheduleToAccessRelation(Schedule); + isl_pw_multi_aff *PWAccRel = MA->applyScheduleToAccessRelation(Schedule); // isl cannot generate an index expression for access-nothing accesses. isl::set AccDomain = @@ -987,7 +987,7 @@ } else if (S.getStmtFor(Inst)) { IsDead = false; } else { - auto *Domain = S.getDomainConditions(Inst->getParent()); + isl_set *Domain = S.getDomainConditions(Inst->getParent()); IsDead = isl_set_is_empty(Domain); isl_set_free(Domain); } Index: lib/CodeGen/PPCGCodeGeneration.cpp =================================================================== --- lib/CodeGen/PPCGCodeGeneration.cpp +++ lib/CodeGen/PPCGCodeGeneration.cpp @@ -2415,7 +2415,7 @@ S->getIslCtx(), S->getNumParams() + std::distance(S->array_begin(), S->array_end())); auto *Zero = isl_ast_expr_from_val(isl_val_zero(S->getIslCtx())); - auto *Space = S->getParamSpace(); + isl_space *Space = S->getParamSpace(); for (int I = 0, E = S->getNumParams(); I < E; ++I) { isl_id *Id = isl_space_get_dim_id(Space, isl_dim_param, I); @@ -2612,8 +2612,7 @@ Extent = isl_set_lower_bound_si(Extent, isl_dim_set, i, 0); for (unsigned i = 0; i < NumDims; ++i) { - isl_pw_aff *PwAff = - const_cast(Array->getDimensionSizePw(i)); + isl_pw_aff *PwAff = Array->getDimensionSizePw(i); // isl_pw_aff can be NULL for zero dimension. Only in the case of a // Fortran array will we have a legitimate dimension. Index: lib/Support/SCEVAffinator.cpp =================================================================== --- lib/Support/SCEVAffinator.cpp +++ lib/Support/SCEVAffinator.cpp @@ -134,7 +134,7 @@ this->BB = BB; if (BB) { - auto *DC = S->getDomainConditions(BB); + isl_set *DC = S->getDomainConditions(BB); NumIterators = isl_set_n_dim(DC); isl_set_free(DC); } else Index: lib/Transform/ScheduleOptimizer.cpp =================================================================== --- lib/Transform/ScheduleOptimizer.cpp +++ lib/Transform/ScheduleOptimizer.cpp @@ -839,7 +839,7 @@ continue; if (!MemAccessPtr->isWrite()) return false; - auto *AccMap = MemAccessPtr->getLatestAccessRelation(); + isl_map *AccMap = MemAccessPtr->getLatestAccessRelation(); if (isl_map_n_basic_map(AccMap) != 1 || !isMatMulOperandAcc(AccMap, MMI.i, MMI.j)) { isl_map_free(AccMap); @@ -1132,14 +1132,14 @@ MMI.B->getElementType(), "Packed_B", {FirstDimSize, SecondDimSize, ThirdDimSize}); AccRel = isl_map_set_tuple_id(AccRel, isl_dim_out, SAI->getBasePtrId()); - auto *OldAcc = MMI.B->getLatestAccessRelation(); + isl_map *OldAcc = MMI.B->getLatestAccessRelation(); MMI.B->setNewAccessRelation(AccRel); auto *ExtMap = isl_map_project_out(isl_map_copy(MapOldIndVar), isl_dim_out, 2, isl_map_dim(MapOldIndVar, isl_dim_out) - 2); ExtMap = isl_map_reverse(ExtMap); ExtMap = isl_map_fix_si(ExtMap, isl_dim_out, MMI.i, 0); - auto *Domain = Stmt->getDomain(); + isl_set *Domain = Stmt->getDomain(); // Restrict the domains of the copy statements to only execute when also its // originating statement is executed. Index: lib/Transform/Simplify.cpp =================================================================== --- lib/Transform/Simplify.cpp +++ lib/Transform/Simplify.cpp @@ -172,7 +172,7 @@ if (!TargetsSpace.has_equal_tuples(AccRelSpace)) continue; - AccRel = AccRel.intersect_domain(give(Acc->getStatement()->getDomain())); + AccRel = AccRel.intersect_domain(Acc->getStatement()->getDomain()); AccRel = AccRel.intersect_params(give(S->getContext())); auto CommonElt = Targets.intersect(AccRel); if (!CommonElt.is_empty()) @@ -190,7 +190,7 @@ /// removed) and the overwrite. void removeOverwrites() { for (auto &Stmt : *S) { - auto Domain = give(Stmt.getDomain()); + auto Domain = Stmt.getDomain(); isl::union_map WillBeOverwritten = isl::union_map::empty(give(S->getParamSpace())); @@ -261,10 +261,10 @@ continue; auto WARel = give(WA->getLatestAccessRelation()); - WARel = WARel.intersect_domain(give(WA->getStatement()->getDomain())); + WARel = WARel.intersect_domain(WA->getStatement()->getDomain()); WARel = WARel.intersect_params(give(S->getContext())); auto RARel = give(RA->getLatestAccessRelation()); - RARel = RARel.intersect_domain(give(RA->getStatement()->getDomain())); + RARel = RARel.intersect_domain(RA->getStatement()->getDomain()); RARel = RARel.intersect_params(give(S->getContext())); if (!RARel.is_equal(WARel)) {