diff options
| author | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-10-06 00:04:11 +0000 |
|---|---|---|
| committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-10-06 00:04:11 +0000 |
| commit | 5d4538129475f9f2456136757a90911474e97895 (patch) | |
| tree | e60385a7e60351d90c1d959c4f34885e82177e65 | |
| parent | cf3942dfa6162d78e591e6356765d4fd769c4864 (diff) | |
| download | bcm5719-llvm-5d4538129475f9f2456136757a90911474e97895.tar.gz bcm5719-llvm-5d4538129475f9f2456136757a90911474e97895.zip | |
ScopInfo: Only give away a copy of the access relation.
Also take the chance and rename access functions to access relations. This is
because we do not only allow plain functions to describe an access, but we
can have any access relation that can be described with linear constraints.
llvm-svn: 141257
| -rwxr-xr-x | polly/include/polly/ScopInfo.h | 11 | ||||
| -rw-r--r-- | polly/lib/Analysis/Dependences.cpp | 2 | ||||
| -rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 18 | ||||
| -rw-r--r-- | polly/lib/CodeGeneration.cpp | 26 | ||||
| -rwxr-xr-x | polly/lib/Exchange/JSONExporter.cpp | 17 |
5 files changed, 43 insertions, 31 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index ac8157d5753..c04e81188ee 100755 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -119,11 +119,10 @@ public: /// @brief Is this a read memory access? bool isRead() const { return Type == MemoryAccess::Read; } - isl_map *getAccessFunction() { return AccessRelation; } - isl_map *getAccessFunction() const { return AccessRelation; } + isl_map *getAccessRelation() const; /// @brief Get an isl string representing this access function. - std::string getAccessFunctionStr() const; + std::string getAccessRelationStr() const; const Value *getBaseAddr() const { return BaseAddr; @@ -134,9 +133,7 @@ public: } /// @brief Get the new access function imported from JSCOP file - isl_map *getNewAccessFunction() { - return newAccessRelation; - } + isl_map *getNewAccessRelation() const; /// @brief Get the stride of this memory access in the specified domain /// subset. @@ -154,7 +151,7 @@ public: ScopStmt *getStatement() const { return statement; } /// @brief Set the updated access relation read from JSCOP file. - void setNewAccessFunction(isl_map *newAccessRelation); + void setNewAccessRelation(isl_map *newAccessRelation); /// @brief Print the MemoryAccess. /// /// @param OS The output stream the MemoryAccess is printed to. diff --git a/polly/lib/Analysis/Dependences.cpp b/polly/lib/Analysis/Dependences.cpp index 4f7e31579f3..8af22dc6980 100644 --- a/polly/lib/Analysis/Dependences.cpp +++ b/polly/lib/Analysis/Dependences.cpp @@ -97,7 +97,7 @@ bool Dependences::runOnScop(Scop &S) { for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(), ME = Stmt->memacc_end(); MI != ME; ++MI) { isl_set *domcp = Stmt->getDomain(); - isl_map *accdom = isl_map_copy((*MI)->getAccessFunction()); + isl_map *accdom = (*MI)->getAccessRelation(); accdom = isl_map_intersect_domain(accdom, domcp); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 9e26179abed..0f21ad3355b 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -295,8 +295,16 @@ void MemoryAccess::setBaseName() { BaseName = "MemRef_" + BaseName; } -std::string MemoryAccess::getAccessFunctionStr() const { - return stringFromIslObj(getAccessFunction()); +isl_map *MemoryAccess::getAccessRelation() const { + return isl_map_copy(AccessRelation); +} + +std::string MemoryAccess::getAccessRelationStr() const { + return stringFromIslObj(AccessRelation); +} + +isl_map *MemoryAccess::getNewAccessRelation() const { + return isl_map_copy(newAccessRelation); } isl_basic_map *MemoryAccess::createBasicAccessMap(ScopStmt *Statement) { @@ -358,7 +366,7 @@ MemoryAccess::MemoryAccess(const Value *BaseAddress, ScopStmt *Statement) { void MemoryAccess::print(raw_ostream &OS) const { OS.indent(12) << (isRead() ? "Read" : "Write") << "Access := \n"; - OS.indent(16) << getAccessFunctionStr() << ";\n"; + OS.indent(16) << getAccessRelationStr() << ";\n"; } void MemoryAccess::dump() const { @@ -424,7 +432,7 @@ static isl_map *getEqualAndLarger(isl_space *setDomain) { } isl_set *MemoryAccess::getStride(const isl_set *domainSubset) const { - isl_map *accessRelation = isl_map_copy(getAccessFunction()); + isl_map *accessRelation = getAccessRelation(); isl_set *scatteringDomain = isl_set_copy(const_cast<isl_set*>(domainSubset)); isl_map *scattering = getStatement()->getScattering(); @@ -506,7 +514,7 @@ bool MemoryAccess::isStrideOne(const isl_set *domainSubset) const { return isStrideOne; } -void MemoryAccess::setNewAccessFunction(isl_map *newAccess) { +void MemoryAccess::setNewAccessRelation(isl_map *newAccess) { isl_map_free(newAccessRelation); newAccessRelation = newAccess; } diff --git a/polly/lib/CodeGeneration.cpp b/polly/lib/CodeGeneration.cpp index 5e155aa46fa..e33970648fc 100644 --- a/polly/lib/CodeGeneration.cpp +++ b/polly/lib/CodeGeneration.cpp @@ -358,22 +358,26 @@ public: /// @brief Generate the operand address Value *generateLocationAccessed(const Instruction *Inst, const Value *pointer, ValueMapT &BBMap ) { - MemoryAccess &access = statement.getAccessFor(Inst); - isl_map *currentAccessRelation = access.getAccessFunction(); - isl_map *newAccessRelation = access.getNewAccessFunction(); + MemoryAccess &Access = statement.getAccessFor(Inst); + isl_map *CurrentAccessRelation = Access.getAccessRelation(); + isl_map *NewAccessRelation = Access.getNewAccessRelation(); - assert(isl_map_has_equal_space(currentAccessRelation, newAccessRelation) + assert(isl_map_has_equal_space(CurrentAccessRelation, NewAccessRelation) && "Current and new access function use different spaces"); - if (!newAccessRelation) { - Value *newPointer = getOperand(pointer, BBMap); - return newPointer; + Value *NewPointer; + + if (!NewAccessRelation) { + NewPointer = getOperand(pointer, BBMap); + } else { + Value *BaseAddr = const_cast<Value*>(Access.getBaseAddr()); + NewPointer = getNewAccessOperand(NewAccessRelation, BaseAddr, pointer, + BBMap); } - Value *baseAddr = const_cast<Value*>(access.getBaseAddr()); - Value *newPointer = getNewAccessOperand(newAccessRelation, baseAddr, - pointer, BBMap); - return newPointer; + isl_map_free(CurrentAccessRelation); + isl_map_free(NewAccessRelation); + return NewPointer; } Value *generateScalarLoad(const LoadInst *load, ValueMapT &BBMap) { diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index aa5d719ad29..3a45cb1a8c7 100755 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -117,7 +117,7 @@ Json::Value JSONExporter::getJSON(Scop &scop) const { Json::Value access; access["kind"] = (*MI)->isRead() ? "read" : "write"; - access["relation"] = (*MI)->getAccessFunctionStr(); + access["relation"] = (*MI)->getAccessRelationStr(); statement["accesses"].append(access); } @@ -247,11 +247,11 @@ bool JSONImporter::runOnScop(Scop &scop) { return false; } - for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) { - ScopStmt *Stmt = *SI; + for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) { + ScopStmt *Stmt = *SI; - if (NewScattering.find(Stmt) != NewScattering.end()) - Stmt->setScattering(NewScattering[Stmt]); + if (NewScattering.find(Stmt) != NewScattering.end()) + Stmt->setScattering(NewScattering[Stmt]); } int statementIdx = 0; @@ -268,15 +268,17 @@ bool JSONImporter::runOnScop(Scop &scop) { ["accesses"][memoryAccessIdx]["relation"]; isl_map *newAccessMap = isl_map_read_from_str(S->getIslCtx(), accesses.asCString()); - isl_map *currentAccessMap = (*MI)->getAccessFunction(); + isl_map *currentAccessMap = (*MI)->getAccessRelation(); if (!isl_map_has_equal_space(currentAccessMap, newAccessMap)) { errs() << "JScop file contains access function with incompatible " << "dimensions\n"; + isl_map_free(currentAccessMap); isl_map_free(newAccessMap); return false; } if (isl_map_dim(newAccessMap, isl_dim_out) != 1) { errs() << "New access map in JScop file should be single dimensional\n"; + isl_map_free(currentAccessMap); isl_map_free(newAccessMap); return false; } @@ -284,10 +286,11 @@ bool JSONImporter::runOnScop(Scop &scop) { // Statistics. ++NewAccessMapFound; newAccessStrings.push_back(accesses.asCString()); - (*MI)->setNewAccessFunction(newAccessMap); + (*MI)->setNewAccessRelation(newAccessMap); } else { isl_map_free(newAccessMap); } + isl_map_free(currentAccessMap); memoryAccessIdx++; } statementIdx++; |

