[polly] r230900 - [Refactor] Remove Scop * member to simplify JSON class
Johannes Doerfert
doerfert at cs.uni-saarland.de
Sun Mar 1 10:44:57 PST 2015
Author: jdoerfert
Date: Sun Mar 1 12:44:57 2015
New Revision: 230900
URL: http://llvm.org/viewvc/llvm-project?rev=230900&view=rev
Log:
[Refactor] Remove Scop * member to simplify JSON class
Modified:
polly/trunk/lib/Exchange/JSONExporter.cpp
Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=230900&r1=230899&r2=230900&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Sun Mar 1 12:44:57 2015
@@ -55,11 +55,10 @@ static cl::opt<std::string>
struct JSONExporter : public ScopPass {
static char ID;
- Scop *S;
explicit JSONExporter() : ScopPass(ID) {}
- std::string getFileName(Scop *S) const;
- Json::Value getJSON(Scop &scop) const;
+ std::string getFileName(Scop &S) const;
+ Json::Value getJSON(Scop &S) const;
virtual bool runOnScop(Scop &S);
void printScop(raw_ostream &OS, Scop &S) const;
void getAnalysisUsage(AnalysisUsage &AU) const;
@@ -67,11 +66,10 @@ struct JSONExporter : public ScopPass {
struct JSONImporter : public ScopPass {
static char ID;
- Scop *S;
std::vector<std::string> newAccessStrings;
explicit JSONImporter() : ScopPass(ID) {}
- std::string getFileName(Scop *S) const;
+ std::string getFileName(Scop &S) const;
virtual bool runOnScop(Scop &S);
void printScop(raw_ostream &OS, Scop &S) const;
void getAnalysisUsage(AnalysisUsage &AU) const;
@@ -79,22 +77,22 @@ struct JSONImporter : public ScopPass {
}
char JSONExporter::ID = 0;
-std::string JSONExporter::getFileName(Scop *S) const {
- std::string FunctionName = S->getRegion().getEntry()->getParent()->getName();
- std::string FileName = FunctionName + "___" + S->getNameStr() + ".jscop";
+std::string JSONExporter::getFileName(Scop &S) const {
+ std::string FunctionName = S.getRegion().getEntry()->getParent()->getName();
+ std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";
return FileName;
}
void JSONExporter::printScop(raw_ostream &OS, Scop &S) const { S.print(OS); }
-Json::Value JSONExporter::getJSON(Scop &scop) const {
+Json::Value JSONExporter::getJSON(Scop &S) const {
Json::Value root;
- root["name"] = S->getRegion().getNameStr();
- root["context"] = S->getContextStr();
+ root["name"] = S.getRegion().getNameStr();
+ root["context"] = S.getContextStr();
root["statements"];
- for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
+ for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
Json::Value statement;
@@ -119,13 +117,12 @@ Json::Value JSONExporter::getJSON(Scop &
return root;
}
-bool JSONExporter::runOnScop(Scop &scop) {
- S = &scop;
- Region &R = S->getRegion();
+bool JSONExporter::runOnScop(Scop &S) {
+ Region &R = S.getRegion();
std::string FileName = ImportDir + "/" + getFileName(S);
- Json::Value jscop = getJSON(scop);
+ Json::Value jscop = getJSON(S);
Json::StyledWriter writer;
std::string fileContent = writer.write(jscop);
@@ -161,9 +158,9 @@ void JSONExporter::getAnalysisUsage(Anal
Pass *polly::createJSONExporterPass() { return new JSONExporter(); }
char JSONImporter::ID = 0;
-std::string JSONImporter::getFileName(Scop *S) const {
- std::string FunctionName = S->getRegion().getEntry()->getParent()->getName();
- std::string FileName = FunctionName + "___" + S->getNameStr() + ".jscop";
+std::string JSONImporter::getFileName(Scop &S) const {
+ std::string FunctionName = S.getRegion().getEntry()->getParent()->getName();
+ std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";
if (ImportPostfix != "")
FileName += "." + ImportPostfix;
@@ -181,9 +178,8 @@ void JSONImporter::printScop(raw_ostream
typedef Dependences::StatementToIslMapTy StatementToIslMapTy;
-bool JSONImporter::runOnScop(Scop &scop) {
- S = &scop;
- Region &R = S->getRegion();
+bool JSONImporter::runOnScop(Scop &S) {
+ Region &R = S.getRegion();
Dependences *D = &getAnalysis<Dependences>();
const DataLayout &DL = getAnalysis<DataLayoutPass>().getDataLayout();
@@ -211,9 +207,9 @@ bool JSONImporter::runOnScop(Scop &scop)
return false;
}
- isl_set *OldContext = S->getContext();
+ isl_set *OldContext = S.getContext();
isl_set *NewContext =
- isl_set_read_from_str(S->getIslCtx(), jscop["context"].asCString());
+ isl_set_read_from_str(S.getIslCtx(), jscop["context"].asCString());
for (unsigned i = 0; i < isl_set_dim(OldContext, isl_dim_param); i++) {
isl_id *id = isl_set_get_dim_id(OldContext, isl_dim_param, i);
@@ -221,15 +217,15 @@ bool JSONImporter::runOnScop(Scop &scop)
}
isl_set_free(OldContext);
- S->setContext(NewContext);
+ S.setContext(NewContext);
StatementToIslMapTy &NewScattering = *(new StatementToIslMapTy());
int index = 0;
- for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
+ for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
Json::Value schedule = jscop["statements"][index]["schedule"];
- isl_map *m = isl_map_read_from_str(S->getIslCtx(), schedule.asCString());
+ isl_map *m = isl_map_read_from_str(S.getIslCtx(), schedule.asCString());
isl_space *Space = (*SI)->getDomainSpace();
// Copy the old tuple id. This is necessary to retain the user pointer,
@@ -251,7 +247,7 @@ bool JSONImporter::runOnScop(Scop &scop)
return false;
}
- for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
+ for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (NewScattering.find(Stmt) != NewScattering.end())
@@ -259,7 +255,7 @@ bool JSONImporter::runOnScop(Scop &scop)
}
int statementIdx = 0;
- for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
+ for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
int memoryAccessIdx = 0;
@@ -267,7 +263,7 @@ bool JSONImporter::runOnScop(Scop &scop)
Json::Value accesses = jscop["statements"][statementIdx]["accesses"]
[memoryAccessIdx]["relation"];
isl_map *newAccessMap =
- isl_map_read_from_str(S->getIslCtx(), accesses.asCString());
+ isl_map_read_from_str(S.getIslCtx(), accesses.asCString());
isl_map *currentAccessMap = MA->getAccessRelation();
if (isl_map_dim(newAccessMap, isl_dim_param) !=
More information about the llvm-commits
mailing list