2011-04-29 14:27:02 +08:00
|
|
|
//===-- JSONExporter.cpp - Export Scops as JSON -------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Export the Scops build by ScopInfo pass as a JSON file.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-03-05 06:43:40 +08:00
|
|
|
#include "polly/DependenceInfo.h"
|
2015-12-21 20:38:56 +08:00
|
|
|
#include "polly/LinkAllPasses.h"
|
2013-05-07 15:31:10 +08:00
|
|
|
#include "polly/Options.h"
|
2011-04-29 14:27:02 +08:00
|
|
|
#include "polly/ScopInfo.h"
|
|
|
|
#include "polly/ScopPass.h"
|
2015-05-03 13:21:36 +08:00
|
|
|
#include "polly/Support/ScopLocation.h"
|
2011-07-13 01:14:03 +08:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2015-03-02 02:51:51 +08:00
|
|
|
#include "llvm/Analysis/RegionInfo.h"
|
2015-03-05 17:48:20 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
2014-04-30 15:26:28 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2013-05-07 16:11:54 +08:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
#include "llvm/Support/ToolOutputFile.h"
|
2016-07-30 17:25:51 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2011-04-29 14:27:02 +08:00
|
|
|
#include "isl/constraint.h"
|
2015-05-09 17:13:42 +08:00
|
|
|
#include "isl/map.h"
|
2011-04-29 14:27:02 +08:00
|
|
|
#include "isl/printer.h"
|
2015-05-09 17:13:42 +08:00
|
|
|
#include "isl/set.h"
|
2015-07-14 17:33:13 +08:00
|
|
|
#include "isl/union_map.h"
|
2015-05-09 17:13:42 +08:00
|
|
|
#include "json/reader.h"
|
|
|
|
#include "json/writer.h"
|
2014-05-19 11:55:49 +08:00
|
|
|
#include <memory>
|
2011-04-29 14:27:02 +08:00
|
|
|
#include <string>
|
2014-06-13 03:22:17 +08:00
|
|
|
#include <system_error>
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace polly;
|
|
|
|
|
2014-04-22 11:30:19 +08:00
|
|
|
#define DEBUG_TYPE "polly-import-jscop"
|
|
|
|
|
2013-03-23 09:05:07 +08:00
|
|
|
STATISTIC(NewAccessMapFound, "Number of updated access functions");
|
2011-07-13 01:14:03 +08:00
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
namespace {
|
2013-05-07 15:30:56 +08:00
|
|
|
static cl::opt<std::string>
|
2014-07-09 18:50:10 +08:00
|
|
|
ImportDir("polly-import-jscop-dir",
|
|
|
|
cl::desc("The directory to import the .jscop files from."),
|
|
|
|
cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired,
|
|
|
|
cl::init("."), cl::cat(PollyCategory));
|
2013-03-23 09:05:07 +08:00
|
|
|
|
2013-05-07 15:30:56 +08:00
|
|
|
static cl::opt<std::string>
|
2014-07-09 18:50:10 +08:00
|
|
|
ImportPostfix("polly-import-jscop-postfix",
|
|
|
|
cl::desc("Postfix to append to the import .jsop files."),
|
|
|
|
cl::Hidden, cl::value_desc("File postfix"), cl::ValueRequired,
|
|
|
|
cl::init(""), cl::cat(PollyCategory));
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
struct JSONExporter : public ScopPass {
|
|
|
|
static char ID;
|
|
|
|
explicit JSONExporter() : ScopPass(ID) {}
|
|
|
|
|
2015-03-02 02:44:57 +08:00
|
|
|
std::string getFileName(Scop &S) const;
|
|
|
|
Json::Value getJSON(Scop &S) const;
|
2015-09-27 23:43:29 +08:00
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Export the SCoP @p S to a JSON file.
|
2015-09-27 23:43:29 +08:00
|
|
|
bool runOnScop(Scop &S) override;
|
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Print the SCoP @p S as it is exported.
|
2015-09-27 23:43:29 +08:00
|
|
|
void printScop(raw_ostream &OS, Scop &S) const override;
|
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Register all analyses and transformation required.
|
2015-09-27 23:43:29 +08:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
2011-04-29 14:27:02 +08:00
|
|
|
};
|
2011-04-29 14:52:36 +08:00
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
struct JSONImporter : public ScopPass {
|
|
|
|
static char ID;
|
2016-07-21 14:56:33 +08:00
|
|
|
std::vector<std::string> NewAccessStrings;
|
2011-04-29 14:27:02 +08:00
|
|
|
explicit JSONImporter() : ScopPass(ID) {}
|
|
|
|
|
2016-07-21 14:56:31 +08:00
|
|
|
/// Import a new context from JScop.
|
|
|
|
///
|
|
|
|
/// @param S The scop to update.
|
|
|
|
/// @param JScop The JScop file describing the new schedule.
|
|
|
|
///
|
|
|
|
/// @returns True if the import succeeded, otherwise False.
|
|
|
|
bool importContext(Scop &S, Json::Value &JScop);
|
|
|
|
|
2016-07-21 14:56:28 +08:00
|
|
|
/// Import a new schedule from JScop.
|
|
|
|
///
|
|
|
|
/// ... and verify that the new schedule does preserve existing data
|
|
|
|
/// dependences.
|
|
|
|
///
|
|
|
|
/// @param S The scop to update.
|
|
|
|
/// @param JScop The JScop file describing the new schedule.
|
|
|
|
/// @param D The data dependences of the @p S.
|
|
|
|
///
|
|
|
|
/// @returns True if the import succeeded, otherwise False.
|
|
|
|
bool importSchedule(Scop &S, Json::Value &JScop, const Dependences &D);
|
|
|
|
|
2016-07-30 17:25:51 +08:00
|
|
|
/// Import new arrays from JScop.
|
|
|
|
///
|
|
|
|
/// @param S The scop to update.
|
|
|
|
/// @param JScop The JScop file describing new arrays.
|
|
|
|
///
|
|
|
|
/// @returns True if the import succeeded, otherwise False.
|
|
|
|
bool importArrays(Scop &S, Json::Value &JScop);
|
|
|
|
|
2016-07-21 14:56:33 +08:00
|
|
|
/// Import new memory accesses from JScop.
|
|
|
|
///
|
|
|
|
/// @param S The scop to update.
|
|
|
|
/// @param JScop The JScop file describing the new schedule.
|
2017-06-08 20:06:15 +08:00
|
|
|
/// @param DL The data layout to assume.
|
2016-07-21 14:56:33 +08:00
|
|
|
///
|
|
|
|
/// @returns True if the import succeeded, otherwise False.
|
|
|
|
bool importAccesses(Scop &S, Json::Value &JScop, const DataLayout &DL);
|
|
|
|
|
2015-03-02 02:44:57 +08:00
|
|
|
std::string getFileName(Scop &S) const;
|
2015-09-27 23:43:29 +08:00
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Import new access functions for SCoP @p S from a JSON file.
|
2015-09-27 23:43:29 +08:00
|
|
|
bool runOnScop(Scop &S) override;
|
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Print the SCoP @p S and the imported access functions.
|
2015-09-27 23:43:29 +08:00
|
|
|
void printScop(raw_ostream &OS, Scop &S) const override;
|
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Register all analyses and transformation required.
|
2015-09-27 23:43:29 +08:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
2011-04-29 14:27:02 +08:00
|
|
|
};
|
2016-06-24 06:17:27 +08:00
|
|
|
} // namespace
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
char JSONExporter::ID = 0;
|
2015-03-02 02:44:57 +08:00
|
|
|
std::string JSONExporter::getFileName(Scop &S) const {
|
2016-05-23 20:38:05 +08:00
|
|
|
std::string FunctionName = S.getFunction().getName();
|
2015-03-02 02:44:57 +08:00
|
|
|
std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";
|
2011-04-29 14:27:02 +08:00
|
|
|
return FileName;
|
|
|
|
}
|
|
|
|
|
2017-07-21 23:35:53 +08:00
|
|
|
void JSONExporter::printScop(raw_ostream &OS, Scop &S) const { OS << S; }
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2016-07-30 17:25:51 +08:00
|
|
|
/// Export all arrays from the Scop.
|
|
|
|
///
|
|
|
|
/// @param S The Scop containing the arrays.
|
|
|
|
///
|
|
|
|
/// @returns Json::Value containing the arrays.
|
|
|
|
Json::Value exportArrays(const Scop &S) {
|
|
|
|
Json::Value Arrays;
|
|
|
|
std::string Buffer;
|
|
|
|
llvm::raw_string_ostream RawStringOstream(Buffer);
|
|
|
|
|
|
|
|
for (auto &SAI : S.arrays()) {
|
|
|
|
if (!SAI->isArrayKind())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Json::Value Array;
|
|
|
|
Array["name"] = SAI->getName();
|
2016-09-13 01:08:31 +08:00
|
|
|
unsigned i = 0;
|
|
|
|
if (!SAI->getDimensionSize(i)) {
|
|
|
|
Array["sizes"].append("*");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
for (; i < SAI->getNumberOfDimensions(); i++) {
|
2016-07-30 17:25:51 +08:00
|
|
|
SAI->getDimensionSize(i)->print(RawStringOstream);
|
|
|
|
Array["sizes"].append(RawStringOstream.str());
|
|
|
|
Buffer.clear();
|
|
|
|
}
|
|
|
|
SAI->getElementType()->print(RawStringOstream);
|
|
|
|
Array["type"] = RawStringOstream.str();
|
|
|
|
Buffer.clear();
|
|
|
|
Arrays.append(Array);
|
|
|
|
}
|
|
|
|
return Arrays;
|
|
|
|
}
|
|
|
|
|
2015-03-02 02:44:57 +08:00
|
|
|
Json::Value JSONExporter::getJSON(Scop &S) const {
|
2011-04-29 14:27:02 +08:00
|
|
|
Json::Value root;
|
2015-05-03 13:21:36 +08:00
|
|
|
unsigned LineBegin, LineEnd;
|
|
|
|
std::string FileName;
|
|
|
|
|
|
|
|
getDebugLocation(&S.getRegion(), LineBegin, LineEnd, FileName);
|
|
|
|
std::string Location;
|
|
|
|
if (LineBegin != (unsigned)-1)
|
|
|
|
Location = FileName + ":" + std::to_string(LineBegin) + "-" +
|
|
|
|
std::to_string(LineEnd);
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2016-05-23 20:38:05 +08:00
|
|
|
root["name"] = S.getNameStr();
|
2015-03-02 02:44:57 +08:00
|
|
|
root["context"] = S.getContextStr();
|
2015-05-03 13:21:36 +08:00
|
|
|
if (LineBegin != (unsigned)-1)
|
|
|
|
root["location"] = Location;
|
2016-07-30 17:25:51 +08:00
|
|
|
|
|
|
|
root["arrays"] = exportArrays(S);
|
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
root["statements"];
|
|
|
|
|
2015-05-27 13:16:57 +08:00
|
|
|
for (ScopStmt &Stmt : S) {
|
2011-04-29 14:27:02 +08:00
|
|
|
Json::Value statement;
|
|
|
|
|
2015-05-27 13:16:57 +08:00
|
|
|
statement["name"] = Stmt.getBaseName();
|
|
|
|
statement["domain"] = Stmt.getDomainStr();
|
|
|
|
statement["schedule"] = Stmt.getScheduleStr();
|
2011-04-29 14:27:02 +08:00
|
|
|
statement["accesses"];
|
|
|
|
|
2015-05-27 13:16:57 +08:00
|
|
|
for (MemoryAccess *MA : Stmt) {
|
2011-04-29 14:27:02 +08:00
|
|
|
Json::Value access;
|
|
|
|
|
2014-06-14 02:01:45 +08:00
|
|
|
access["kind"] = MA->isRead() ? "read" : "write";
|
2017-07-11 18:10:13 +08:00
|
|
|
access["relation"] = MA->getAccessRelationStr();
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
statement["accesses"].append(access);
|
|
|
|
}
|
|
|
|
|
|
|
|
root["statements"].append(statement);
|
|
|
|
}
|
|
|
|
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
|
2015-03-02 02:44:57 +08:00
|
|
|
bool JSONExporter::runOnScop(Scop &S) {
|
2011-04-29 14:27:02 +08:00
|
|
|
std::string FileName = ImportDir + "/" + getFileName(S);
|
|
|
|
|
2015-03-02 02:44:57 +08:00
|
|
|
Json::Value jscop = getJSON(S);
|
2011-04-29 14:27:02 +08:00
|
|
|
Json::StyledWriter writer;
|
|
|
|
std::string fileContent = writer.write(jscop);
|
|
|
|
|
|
|
|
// Write to file.
|
2014-08-26 02:16:52 +08:00
|
|
|
std::error_code EC;
|
|
|
|
tool_output_file F(FileName, EC, llvm::sys::fs::F_Text);
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2016-05-23 20:38:05 +08:00
|
|
|
std::string FunctionName = S.getFunction().getName();
|
|
|
|
errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
|
2013-03-23 09:05:07 +08:00
|
|
|
<< FunctionName << "' to '" << FileName << "'.\n";
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2014-08-26 02:16:52 +08:00
|
|
|
if (!EC) {
|
2011-04-29 14:27:02 +08:00
|
|
|
F.os() << fileContent;
|
|
|
|
F.os().close();
|
|
|
|
if (!F.os().has_error()) {
|
|
|
|
errs() << "\n";
|
|
|
|
F.keep();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
errs() << " error opening file for writing!\n";
|
|
|
|
F.os().clear_error();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSONExporter::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
2016-05-31 17:41:04 +08:00
|
|
|
AU.addRequired<ScopInfoRegionPass>();
|
2011-04-29 14:27:02 +08:00
|
|
|
}
|
|
|
|
|
2013-03-23 09:05:07 +08:00
|
|
|
Pass *polly::createJSONExporterPass() { return new JSONExporter(); }
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
char JSONImporter::ID = 0;
|
2015-03-02 02:44:57 +08:00
|
|
|
std::string JSONImporter::getFileName(Scop &S) const {
|
2016-05-23 20:38:05 +08:00
|
|
|
std::string FunctionName = S.getFunction().getName();
|
2015-03-02 02:44:57 +08:00
|
|
|
std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
if (ImportPostfix != "")
|
|
|
|
FileName += "." + ImportPostfix;
|
|
|
|
|
|
|
|
return FileName;
|
|
|
|
}
|
2011-04-29 14:52:36 +08:00
|
|
|
|
2015-03-02 02:40:25 +08:00
|
|
|
void JSONImporter::printScop(raw_ostream &OS, Scop &S) const {
|
2017-07-21 23:35:53 +08:00
|
|
|
OS << S;
|
2016-07-21 14:56:33 +08:00
|
|
|
for (std::vector<std::string>::const_iterator I = NewAccessStrings.begin(),
|
|
|
|
E = NewAccessStrings.end();
|
2013-03-23 09:05:07 +08:00
|
|
|
I != E; I++)
|
2016-08-26 23:43:52 +08:00
|
|
|
OS << "New access function '" << *I << "' detected in JSCOP file\n";
|
2011-04-29 14:27:02 +08:00
|
|
|
}
|
|
|
|
|
2015-03-05 08:43:48 +08:00
|
|
|
typedef Dependences::StatementToIslMapTy StatementToIslMapTy;
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2016-07-21 14:56:31 +08:00
|
|
|
bool JSONImporter::importContext(Scop &S, Json::Value &JScop) {
|
|
|
|
isl_set *OldContext = S.getContext();
|
2017-05-24 23:09:35 +08:00
|
|
|
|
|
|
|
// Check if key 'context' is present.
|
|
|
|
if (!JScop.isMember("context")) {
|
|
|
|
errs() << "JScop file has no key named 'context'.\n";
|
|
|
|
isl_set_free(OldContext);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:31 +08:00
|
|
|
isl_set *NewContext =
|
|
|
|
isl_set_read_from_str(S.getIslCtx(), JScop["context"].asCString());
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check whether the context was parsed successfully.
|
|
|
|
if (!NewContext) {
|
|
|
|
errs() << "The context was not parsed successfully by ISL.\n";
|
|
|
|
isl_set_free(NewContext);
|
|
|
|
isl_set_free(OldContext);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the isl_set is a parameter set.
|
|
|
|
if (!isl_set_is_params(NewContext)) {
|
|
|
|
errs() << "The isl_set is not a parameter set.\n";
|
|
|
|
isl_set_free(NewContext);
|
|
|
|
isl_set_free(OldContext);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned OldContextDim = isl_set_dim(OldContext, isl_dim_param);
|
|
|
|
unsigned NewContextDim = isl_set_dim(NewContext, isl_dim_param);
|
|
|
|
|
|
|
|
// Check if the imported context has the right number of parameters.
|
|
|
|
if (OldContextDim != NewContextDim) {
|
|
|
|
errs() << "Imported context has the wrong number of parameters : "
|
|
|
|
<< "Found " << NewContextDim << " Expected " << OldContextDim
|
|
|
|
<< "\n";
|
|
|
|
isl_set_free(NewContext);
|
|
|
|
isl_set_free(OldContext);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < OldContextDim; i++) {
|
2016-07-21 14:56:31 +08:00
|
|
|
isl_id *Id = isl_set_get_dim_id(OldContext, isl_dim_param, i);
|
|
|
|
NewContext = isl_set_set_dim_id(NewContext, isl_dim_param, i, Id);
|
|
|
|
}
|
|
|
|
|
|
|
|
isl_set_free(OldContext);
|
|
|
|
S.setContext(NewContext);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:28 +08:00
|
|
|
bool JSONImporter::importSchedule(Scop &S, Json::Value &JScop,
|
|
|
|
const Dependences &D) {
|
|
|
|
StatementToIslMapTy NewSchedule;
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if key 'statements' is present.
|
|
|
|
if (!JScop.isMember("statements")) {
|
|
|
|
errs() << "JScop file has no key name 'statements'.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value statements = JScop["statements"];
|
|
|
|
|
|
|
|
// Check whether the number of indices equals the number of statements
|
|
|
|
if (statements.size() != S.getSize()) {
|
|
|
|
errs() << "The number of indices and the number of statements differ.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:28 +08:00
|
|
|
int Index = 0;
|
|
|
|
for (ScopStmt &Stmt : S) {
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if key 'schedule' is present.
|
|
|
|
if (!statements[Index].isMember("schedule")) {
|
|
|
|
errs() << "Statement " << Index << " has no 'schedule' key.\n";
|
|
|
|
for (auto Element : NewSchedule) {
|
|
|
|
isl_map_free(Element.second);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Json::Value Schedule = statements[Index]["schedule"];
|
2016-09-14 14:26:09 +08:00
|
|
|
assert(!Schedule.asString().empty() &&
|
|
|
|
"Schedules that contain extension nodes require special handling.");
|
2016-07-21 14:56:28 +08:00
|
|
|
isl_map *Map = isl_map_read_from_str(S.getIslCtx(), Schedule.asCString());
|
2017-05-24 23:09:35 +08:00
|
|
|
|
|
|
|
// Check whether the schedule was parsed successfully
|
|
|
|
if (!Map) {
|
|
|
|
errs() << "The schedule was not parsed successfully (index = " << Index
|
|
|
|
<< ").\n";
|
|
|
|
for (auto Element : NewSchedule) {
|
|
|
|
isl_map_free(Element.second);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:28 +08:00
|
|
|
isl_space *Space = Stmt.getDomainSpace();
|
|
|
|
|
|
|
|
// Copy the old tuple id. This is necessary to retain the user pointer,
|
|
|
|
// that stores the reference to the ScopStmt this schedule belongs to.
|
|
|
|
Map = isl_map_set_tuple_id(Map, isl_dim_in,
|
|
|
|
isl_space_get_tuple_id(Space, isl_dim_set));
|
|
|
|
for (unsigned i = 0; i < isl_space_dim(Space, isl_dim_param); i++) {
|
|
|
|
isl_id *Id = isl_space_get_dim_id(Space, isl_dim_param, i);
|
|
|
|
Map = isl_map_set_dim_id(Map, isl_dim_param, i, Id);
|
|
|
|
}
|
|
|
|
isl_space_free(Space);
|
|
|
|
NewSchedule[&Stmt] = Map;
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check whether the new schedule is valid or not.
|
2016-07-21 14:56:28 +08:00
|
|
|
if (!D.isValidSchedule(S, &NewSchedule)) {
|
|
|
|
errs() << "JScop file contains a schedule that changes the "
|
|
|
|
<< "dependences. Use -disable-polly-legality to continue anyways\n";
|
|
|
|
for (auto Element : NewSchedule)
|
|
|
|
isl_map_free(Element.second);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ScheduleMap = isl_union_map_empty(S.getParamSpace());
|
|
|
|
for (ScopStmt &Stmt : S) {
|
|
|
|
if (NewSchedule.find(&Stmt) != NewSchedule.end())
|
|
|
|
ScheduleMap = isl_union_map_add_map(ScheduleMap, NewSchedule[&Stmt]);
|
|
|
|
else
|
|
|
|
ScheduleMap = isl_union_map_add_map(ScheduleMap, Stmt.getSchedule());
|
|
|
|
}
|
|
|
|
|
|
|
|
S.setSchedule(ScheduleMap);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:33 +08:00
|
|
|
bool JSONImporter::importAccesses(Scop &S, Json::Value &JScop,
|
|
|
|
const DataLayout &DL) {
|
|
|
|
int StatementIdx = 0;
|
2017-05-24 23:09:35 +08:00
|
|
|
|
|
|
|
// Check if key 'statements' is present.
|
|
|
|
if (!JScop.isMember("statements")) {
|
|
|
|
errs() << "JScop file has no key name 'statements'.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Json::Value statements = JScop["statements"];
|
|
|
|
|
|
|
|
// Check whether the number of indices equals the number of statements
|
|
|
|
if (statements.size() != S.getSize()) {
|
|
|
|
errs() << "The number of indices and the number of statements differ.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-27 13:16:57 +08:00
|
|
|
for (ScopStmt &Stmt : S) {
|
2016-07-21 14:56:33 +08:00
|
|
|
int MemoryAccessIdx = 0;
|
2017-05-24 23:09:35 +08:00
|
|
|
|
|
|
|
// Check if key 'accesses' is present.
|
|
|
|
if (!statements[StatementIdx].isMember("accesses")) {
|
|
|
|
errs()
|
|
|
|
<< "Statement from JScop file has no key name 'accesses' for index "
|
|
|
|
<< StatementIdx << ".\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the number of indices equals the number of memory accesses
|
|
|
|
if (Stmt.size() != statements[StatementIdx]["accesses"].size()) {
|
|
|
|
errs() << "The number of memory accesses in the JSop file and the number "
|
|
|
|
"of memory accesses differ for index "
|
|
|
|
<< StatementIdx << ".\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-27 13:16:57 +08:00
|
|
|
for (MemoryAccess *MA : Stmt) {
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if key 'relation' is present.
|
|
|
|
Json::Value JsonMemoryAccess =
|
|
|
|
statements[StatementIdx]["accesses"][MemoryAccessIdx];
|
|
|
|
if (!JsonMemoryAccess.isMember("relation")) {
|
|
|
|
errs() << "Memory access number " << MemoryAccessIdx
|
|
|
|
<< " has no key name 'relation' for statement number "
|
|
|
|
<< StatementIdx << ".\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Json::Value Accesses = JsonMemoryAccess["relation"];
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map *NewAccessMap =
|
|
|
|
isl_map_read_from_str(S.getIslCtx(), Accesses.asCString());
|
2017-05-24 23:09:35 +08:00
|
|
|
|
|
|
|
// Check whether the access was parsed successfully
|
|
|
|
if (!NewAccessMap) {
|
|
|
|
errs() << "The access was not parsed successfully by ISL.\n";
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map *CurrentAccessMap = MA->getAccessRelation();
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if the number of parameter change
|
2016-07-21 14:56:33 +08:00
|
|
|
if (isl_map_dim(NewAccessMap, isl_dim_param) !=
|
|
|
|
isl_map_dim(CurrentAccessMap, isl_dim_param)) {
|
2017-05-24 23:09:35 +08:00
|
|
|
errs() << "JScop file changes the number of parameter dimensions.\n";
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map_free(CurrentAccessMap);
|
|
|
|
isl_map_free(NewAccessMap);
|
2011-11-15 19:38:59 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-30 17:25:51 +08:00
|
|
|
isl_id *NewOutId;
|
|
|
|
|
2016-09-02 03:53:31 +08:00
|
|
|
// If the NewAccessMap has zero dimensions, it is the scalar access; it
|
|
|
|
// must be the same as before.
|
|
|
|
// If it has at least one dimension, it's an array access; search for its
|
|
|
|
// ScopArrayInfo.
|
|
|
|
if (isl_map_dim(NewAccessMap, isl_dim_out) >= 1) {
|
2016-07-30 17:25:51 +08:00
|
|
|
NewOutId = isl_map_get_tuple_id(NewAccessMap, isl_dim_out);
|
|
|
|
auto *SAI = S.getArrayInfoByName(isl_id_get_name(NewOutId));
|
|
|
|
isl_id *OutId = isl_map_get_tuple_id(CurrentAccessMap, isl_dim_out);
|
|
|
|
auto *OutSAI = ScopArrayInfo::getFromId(OutId);
|
|
|
|
if (!SAI || SAI->getElementType() != OutSAI->getElementType()) {
|
|
|
|
errs() << "JScop file contains access function with undeclared "
|
|
|
|
"ScopArrayInfo\n";
|
|
|
|
isl_map_free(CurrentAccessMap);
|
|
|
|
isl_map_free(NewAccessMap);
|
|
|
|
isl_id_free(NewOutId);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
isl_id_free(NewOutId);
|
2017-07-22 07:07:56 +08:00
|
|
|
NewOutId = SAI->getBasePtrId().release();
|
2016-07-30 17:25:51 +08:00
|
|
|
} else {
|
|
|
|
NewOutId = isl_map_get_tuple_id(CurrentAccessMap, isl_dim_out);
|
|
|
|
}
|
|
|
|
|
|
|
|
NewAccessMap = isl_map_set_tuple_id(NewAccessMap, isl_dim_out, NewOutId);
|
2014-10-05 19:32:18 +08:00
|
|
|
|
2016-01-16 00:49:33 +08:00
|
|
|
if (MA->isArrayKind()) {
|
|
|
|
// We keep the old alignment, thus we cannot allow accesses to memory
|
|
|
|
// locations that were not accessed before if the alignment of the
|
|
|
|
// access is not the default alignment.
|
|
|
|
bool SpecialAlignment = true;
|
|
|
|
if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {
|
|
|
|
SpecialAlignment =
|
2016-09-02 03:53:31 +08:00
|
|
|
LoadI->getAlignment() &&
|
2016-01-16 00:49:33 +08:00
|
|
|
DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment();
|
|
|
|
} else if (StoreInst *StoreI =
|
|
|
|
dyn_cast<StoreInst>(MA->getAccessInstruction())) {
|
|
|
|
SpecialAlignment =
|
2016-09-02 03:53:31 +08:00
|
|
|
StoreI->getAlignment() &&
|
2016-01-16 00:49:33 +08:00
|
|
|
DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) !=
|
2016-09-02 03:53:31 +08:00
|
|
|
StoreI->getAlignment();
|
2016-01-16 00:49:33 +08:00
|
|
|
}
|
2014-10-10 23:14:29 +08:00
|
|
|
|
2016-01-16 00:49:33 +08:00
|
|
|
if (SpecialAlignment) {
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_set *NewAccessSet = isl_map_range(isl_map_copy(NewAccessMap));
|
|
|
|
isl_set *CurrentAccessSet =
|
|
|
|
isl_map_range(isl_map_copy(CurrentAccessMap));
|
|
|
|
bool IsSubset = isl_set_is_subset(NewAccessSet, CurrentAccessSet);
|
|
|
|
isl_set_free(NewAccessSet);
|
|
|
|
isl_set_free(CurrentAccessSet);
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if the JScop file changes the accessed memory.
|
2016-07-21 14:56:33 +08:00
|
|
|
if (!IsSubset) {
|
2016-01-16 00:49:33 +08:00
|
|
|
errs() << "JScop file changes the accessed memory\n";
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map_free(CurrentAccessMap);
|
|
|
|
isl_map_free(NewAccessMap);
|
2016-01-16 00:49:33 +08:00
|
|
|
return false;
|
|
|
|
}
|
2014-10-10 23:14:29 +08:00
|
|
|
}
|
2014-10-03 00:22:19 +08:00
|
|
|
}
|
|
|
|
|
2011-11-15 19:38:59 +08:00
|
|
|
// We need to copy the isl_ids for the parameter dimensions to the new
|
|
|
|
// map. Without doing this the current map would have different
|
|
|
|
// ids then the new one, even though both are named identically.
|
2016-07-21 14:56:33 +08:00
|
|
|
for (unsigned i = 0; i < isl_map_dim(CurrentAccessMap, isl_dim_param);
|
2011-11-15 19:38:59 +08:00
|
|
|
i++) {
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_id *Id = isl_map_get_dim_id(CurrentAccessMap, isl_dim_param, i);
|
|
|
|
NewAccessMap = isl_map_set_dim_id(NewAccessMap, isl_dim_param, i, Id);
|
2011-11-15 19:38:59 +08:00
|
|
|
}
|
|
|
|
|
2012-05-29 17:29:44 +08:00
|
|
|
// Copy the old tuple id. This is necessary to retain the user pointer,
|
|
|
|
// that stores the reference to the ScopStmt this access belongs to.
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_id *Id = isl_map_get_tuple_id(CurrentAccessMap, isl_dim_in);
|
|
|
|
NewAccessMap = isl_map_set_tuple_id(NewAccessMap, isl_dim_in, Id);
|
2012-05-29 17:29:44 +08:00
|
|
|
|
2016-07-30 17:25:51 +08:00
|
|
|
auto NewAccessDomain = isl_map_domain(isl_map_copy(NewAccessMap));
|
|
|
|
auto CurrentAccessDomain = isl_map_domain(isl_map_copy(CurrentAccessMap));
|
|
|
|
|
|
|
|
if (!isl_set_has_equal_space(NewAccessDomain, CurrentAccessDomain)) {
|
2011-08-15 10:33:39 +08:00
|
|
|
errs() << "JScop file contains access function with incompatible "
|
|
|
|
<< "dimensions\n";
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map_free(CurrentAccessMap);
|
|
|
|
isl_map_free(NewAccessMap);
|
2016-07-30 17:25:51 +08:00
|
|
|
isl_set_free(NewAccessDomain);
|
|
|
|
isl_set_free(CurrentAccessDomain);
|
2011-08-15 10:33:39 +08:00
|
|
|
return false;
|
|
|
|
}
|
2015-06-04 15:44:35 +08:00
|
|
|
|
|
|
|
NewAccessDomain =
|
|
|
|
isl_set_intersect_params(NewAccessDomain, S.getContext());
|
|
|
|
CurrentAccessDomain =
|
|
|
|
isl_set_intersect_params(CurrentAccessDomain, S.getContext());
|
|
|
|
|
2017-05-22 06:46:57 +08:00
|
|
|
if (MA->isRead() &&
|
|
|
|
isl_set_is_subset(CurrentAccessDomain, NewAccessDomain) ==
|
|
|
|
isl_bool_false) {
|
2015-06-04 15:44:35 +08:00
|
|
|
errs() << "Mapping not defined for all iteration domain elements\n";
|
|
|
|
isl_set_free(CurrentAccessDomain);
|
|
|
|
isl_set_free(NewAccessDomain);
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map_free(CurrentAccessMap);
|
|
|
|
isl_map_free(NewAccessMap);
|
2015-06-04 15:44:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
isl_set_free(CurrentAccessDomain);
|
|
|
|
isl_set_free(NewAccessDomain);
|
|
|
|
|
2016-07-21 14:56:33 +08:00
|
|
|
if (!isl_map_is_equal(NewAccessMap, CurrentAccessMap)) {
|
2011-07-13 01:14:03 +08:00
|
|
|
// Statistics.
|
|
|
|
++NewAccessMapFound;
|
2016-07-21 14:56:33 +08:00
|
|
|
NewAccessStrings.push_back(Accesses.asCString());
|
|
|
|
MA->setNewAccessRelation(NewAccessMap);
|
2011-08-20 19:11:25 +08:00
|
|
|
} else {
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map_free(NewAccessMap);
|
2011-07-13 01:14:03 +08:00
|
|
|
}
|
2016-07-21 14:56:33 +08:00
|
|
|
isl_map_free(CurrentAccessMap);
|
|
|
|
MemoryAccessIdx++;
|
2011-07-13 01:14:03 +08:00
|
|
|
}
|
2016-07-21 14:56:33 +08:00
|
|
|
StatementIdx++;
|
2011-07-13 01:14:03 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:33 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Check whether @p SAI and @p Array represent the same array.
|
2016-07-30 17:25:51 +08:00
|
|
|
bool areArraysEqual(ScopArrayInfo *SAI, Json::Value Array) {
|
|
|
|
std::string Buffer;
|
|
|
|
llvm::raw_string_ostream RawStringOstream(Buffer);
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if key 'type' is present.
|
|
|
|
if (!Array.isMember("type")) {
|
|
|
|
errs() << "Array has no key 'type'.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if key 'sizes' is present.
|
|
|
|
if (!Array.isMember("sizes")) {
|
|
|
|
errs() << "Array has no key 'sizes'.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if key 'name' is present.
|
|
|
|
if (!Array.isMember("name")) {
|
|
|
|
errs() << "Array has no key 'name'.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-30 17:25:51 +08:00
|
|
|
if (SAI->getName() != Array["name"].asCString())
|
|
|
|
return false;
|
|
|
|
|
2016-09-13 01:08:31 +08:00
|
|
|
if (SAI->getNumberOfDimensions() != Array["sizes"].size())
|
2016-07-30 17:25:51 +08:00
|
|
|
return false;
|
|
|
|
|
2016-09-13 01:08:31 +08:00
|
|
|
for (unsigned i = 1; i < Array["sizes"].size(); i++) {
|
|
|
|
SAI->getDimensionSize(i)->print(RawStringOstream);
|
2016-07-30 17:25:51 +08:00
|
|
|
if (RawStringOstream.str() != Array["sizes"][i].asCString())
|
|
|
|
return false;
|
|
|
|
Buffer.clear();
|
|
|
|
}
|
|
|
|
|
2017-05-24 23:09:35 +08:00
|
|
|
// Check if key 'type' differs from the current one or is not valid.
|
2016-07-30 17:25:51 +08:00
|
|
|
SAI->getElementType()->print(RawStringOstream);
|
2017-05-24 23:09:35 +08:00
|
|
|
if (RawStringOstream.str() != Array["type"].asCString()) {
|
|
|
|
errs() << "Array has not a valid type.\n";
|
2016-07-30 17:25:51 +08:00
|
|
|
return false;
|
2017-05-24 23:09:35 +08:00
|
|
|
}
|
2016-07-30 17:25:51 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-02 14:33:33 +08:00
|
|
|
/// Get the accepted primitive type from its textual representation
|
2016-07-30 17:25:51 +08:00
|
|
|
/// @p TypeTextRepresentation.
|
|
|
|
///
|
|
|
|
/// @param TypeTextRepresentation The textual representation of the type.
|
|
|
|
/// @return The pointer to the primitive type, if this type is accepted
|
|
|
|
/// or nullptr otherwise.
|
|
|
|
Type *parseTextType(const std::string &TypeTextRepresentation,
|
|
|
|
LLVMContext &LLVMContext) {
|
|
|
|
std::map<std::string, Type *> MapStrToType = {
|
|
|
|
{"void", Type::getVoidTy(LLVMContext)},
|
|
|
|
{"half", Type::getHalfTy(LLVMContext)},
|
|
|
|
{"float", Type::getFloatTy(LLVMContext)},
|
|
|
|
{"double", Type::getDoubleTy(LLVMContext)},
|
|
|
|
{"x86_fp80", Type::getX86_FP80Ty(LLVMContext)},
|
|
|
|
{"fp128", Type::getFP128Ty(LLVMContext)},
|
|
|
|
{"ppc_fp128", Type::getPPC_FP128Ty(LLVMContext)},
|
|
|
|
{"i1", Type::getInt1Ty(LLVMContext)},
|
|
|
|
{"i8", Type::getInt8Ty(LLVMContext)},
|
|
|
|
{"i16", Type::getInt16Ty(LLVMContext)},
|
|
|
|
{"i32", Type::getInt32Ty(LLVMContext)},
|
|
|
|
{"i64", Type::getInt64Ty(LLVMContext)},
|
|
|
|
{"i128", Type::getInt128Ty(LLVMContext)}};
|
|
|
|
|
|
|
|
auto It = MapStrToType.find(TypeTextRepresentation);
|
|
|
|
if (It != MapStrToType.end())
|
|
|
|
return It->second;
|
|
|
|
|
|
|
|
errs() << "Textual representation can not be parsed: "
|
|
|
|
<< TypeTextRepresentation << "\n";
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JSONImporter::importArrays(Scop &S, Json::Value &JScop) {
|
|
|
|
Json::Value Arrays = JScop["arrays"];
|
|
|
|
if (Arrays.size() == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
unsigned ArrayIdx = 0;
|
|
|
|
for (auto &SAI : S.arrays()) {
|
|
|
|
if (!SAI->isArrayKind())
|
|
|
|
continue;
|
2017-06-07 03:17:32 +08:00
|
|
|
if (ArrayIdx + 1 > Arrays.size()) {
|
|
|
|
errs() << "Not enough array entries in JScop file.\n";
|
2016-07-30 17:25:51 +08:00
|
|
|
return false;
|
2017-06-07 03:17:32 +08:00
|
|
|
}
|
|
|
|
if (!areArraysEqual(SAI, Arrays[ArrayIdx])) {
|
|
|
|
errs() << "No match for array '" << SAI->getName() << "' in JScop.\n";
|
2016-07-30 17:25:51 +08:00
|
|
|
return false;
|
2017-06-07 03:17:32 +08:00
|
|
|
}
|
2016-07-30 17:25:51 +08:00
|
|
|
ArrayIdx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; ArrayIdx < Arrays.size(); ArrayIdx++) {
|
2017-06-28 21:02:43 +08:00
|
|
|
auto &Array = Arrays[ArrayIdx];
|
|
|
|
auto *ElementType =
|
|
|
|
parseTextType(Array["type"].asCString(), S.getSE()->getContext());
|
2017-06-07 03:17:32 +08:00
|
|
|
if (!ElementType) {
|
|
|
|
errs() << "Error while parsing element type for new array.\n";
|
2016-07-30 17:25:51 +08:00
|
|
|
return false;
|
2017-06-07 03:17:32 +08:00
|
|
|
}
|
2016-07-30 17:25:51 +08:00
|
|
|
std::vector<unsigned> DimSizes;
|
2017-06-28 21:02:43 +08:00
|
|
|
for (unsigned i = 0; i < Array["sizes"].size(); i++) {
|
|
|
|
auto Size = std::stoi(Array["sizes"][i].asCString());
|
2017-06-28 06:30:44 +08:00
|
|
|
|
|
|
|
// Check if the size if positive.
|
|
|
|
if (Size <= 0) {
|
|
|
|
errs() << "The size at index " << i << " is =< 0.\n";
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-28 21:02:43 +08:00
|
|
|
|
|
|
|
DimSizes.push_back(Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto NewSAI =
|
|
|
|
S.createScopArrayInfo(ElementType, Array["name"].asCString(), DimSizes);
|
|
|
|
|
|
|
|
if (Array.isMember("allocation")) {
|
|
|
|
NewSAI->setIsOnHeap(Array["allocation"].asString() == "heap");
|
2017-06-28 06:30:44 +08:00
|
|
|
}
|
2016-07-30 17:25:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:56:33 +08:00
|
|
|
bool JSONImporter::runOnScop(Scop &S) {
|
|
|
|
const Dependences &D =
|
|
|
|
getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
|
|
|
|
const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
|
|
|
|
|
|
|
|
std::string FileName = ImportDir + "/" + getFileName(S);
|
|
|
|
|
|
|
|
std::string FunctionName = S.getFunction().getName();
|
|
|
|
errs() << "Reading JScop '" << S.getNameStr() << "' in function '"
|
|
|
|
<< FunctionName << "' from '" << FileName << "'.\n";
|
|
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> result =
|
|
|
|
MemoryBuffer::getFile(FileName);
|
|
|
|
std::error_code ec = result.getError();
|
|
|
|
|
|
|
|
if (ec) {
|
|
|
|
errs() << "File could not be read: " << ec.message() << "\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Reader reader;
|
|
|
|
Json::Value jscop;
|
|
|
|
|
|
|
|
bool parsingSuccessful = reader.parse(result.get()->getBufferStart(), jscop);
|
|
|
|
|
|
|
|
if (!parsingSuccessful) {
|
|
|
|
errs() << "JSCoP file could not be parsed\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Success = importContext(S, jscop);
|
|
|
|
|
|
|
|
if (!Success)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Success = importSchedule(S, jscop, D);
|
|
|
|
|
2016-07-30 17:25:51 +08:00
|
|
|
if (!Success)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Success = importArrays(S, jscop);
|
|
|
|
|
2016-07-21 14:56:33 +08:00
|
|
|
if (!Success)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Success = importAccesses(S, jscop, DL);
|
|
|
|
|
|
|
|
if (!Success)
|
|
|
|
return false;
|
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
ScopPass::getAnalysisUsage(AU);
|
2015-03-05 06:43:40 +08:00
|
|
|
AU.addRequired<DependenceInfo>();
|
2011-04-29 14:27:02 +08:00
|
|
|
}
|
2015-09-27 23:43:29 +08:00
|
|
|
|
2013-03-23 09:05:07 +08:00
|
|
|
Pass *polly::createJSONImporterPass() { return new JSONImporter(); }
|
|
|
|
|
|
|
|
INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop",
|
|
|
|
"Polly - Export Scops as JSON"
|
|
|
|
" (Writes a .jscop file for each Scop)",
|
|
|
|
false, false);
|
2015-03-05 06:43:40 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
|
2013-03-23 09:05:07 +08:00
|
|
|
INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop",
|
|
|
|
"Polly - Export Scops as JSON"
|
|
|
|
" (Writes a .jscop file for each Scop)",
|
|
|
|
false, false)
|
|
|
|
|
2011-11-15 19:38:36 +08:00
|
|
|
INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop",
|
|
|
|
"Polly - Import Scops from JSON"
|
2013-03-23 09:05:07 +08:00
|
|
|
" (Reads a .jscop file for each Scop)",
|
|
|
|
false, false);
|
2015-03-05 06:43:40 +08:00
|
|
|
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
|
2011-11-15 19:38:36 +08:00
|
|
|
INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop",
|
|
|
|
"Polly - Import Scops from JSON"
|
2013-03-23 09:05:07 +08:00
|
|
|
" (Reads a .jscop file for each Scop)",
|
|
|
|
false, false)
|