forked from OSchip/llvm-project
[Refactor] Remove Scop * member to simplify JSON class
llvm-svn: 230900
This commit is contained in:
parent
2495cfe01d
commit
f94d5178a5
|
@ -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 &scop) const {
|
|||
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(AnalysisUsage &AU) const {
|
|||
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 &OS, Scop &S) const {
|
|||
|
||||
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) !=
|
||||
|
|
Loading…
Reference in New Issue