#include "polly/JSONExporter.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
#include "polly/ScopPass.h"
#include "polly/Support/ISLTools.h"
#include "polly/Support/ScopLocation.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/raw_ostream.h"
#include "isl/map.h"
#include "isl/set.h"
#include <memory>
#include <string>
#include <system_error>
usingnamespacellvm;
usingnamespacepolly;
#define DEBUG_TYPE …
STATISTIC(NewAccessMapFound, "Number of updated access functions");
namespace {
static cl::opt<std::string>
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));
static cl::opt<std::string>
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));
class JSONExporter : public ScopPass { … };
class JSONImporter : public ScopPass { … };
}
static std::string getFileName(Scop &S, StringRef Suffix = "") { … }
static json::Array exportArrays(const Scop &S) { … }
static json::Value getJSON(Scop &S) { … }
static void exportScop(Scop &S) { … }
StatementToIslMapTy;
static bool importContext(Scop &S, const json::Object &JScop) { … }
static bool importSchedule(Scop &S, const json::Object &JScop,
const Dependences &D) { … }
static bool
importAccesses(Scop &S, const json::Object &JScop, const DataLayout &DL,
std::vector<std::string> *NewAccessStrings = nullptr) { … }
static bool areArraysEqual(ScopArrayInfo *SAI, const json::Object &Array) { … }
static Type *parseTextType(const std::string &TypeTextRepresentation,
LLVMContext &LLVMContext) { … }
static bool importArrays(Scop &S, const json::Object &JScop) { … }
static bool importScop(Scop &S, const Dependences &D, const DataLayout &DL,
std::vector<std::string> *NewAccessStrings = nullptr) { … }
char JSONExporter::ID = …;
void JSONExporter::printScop(raw_ostream &OS, Scop &S) const { … }
bool JSONExporter::runOnScop(Scop &S) { … }
void JSONExporter::getAnalysisUsage(AnalysisUsage &AU) const { … }
Pass *polly::createJSONExporterPass() { … }
PreservedAnalyses JSONExportPass::run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR,
SPMUpdater &) { … }
char JSONImporter::ID = …;
void JSONImporter::printScop(raw_ostream &OS, Scop &S) const { … }
bool JSONImporter::runOnScop(Scop &S) { … }
void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const { … }
Pass *polly::createJSONImporterPass() { … }
PreservedAnalyses JSONImportPass::run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR,
SPMUpdater &) { … }
INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop",
"Polly - Export Scops as JSON"
" (Writes a .jscop file for each Scop)",
false, false);
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop",
"Polly - Export Scops as JSON"
" (Writes a .jscop file for each Scop)",
false, false)
INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop",
"Polly - Import Scops from JSON"
" (Reads a .jscop file for each Scop)",
false, false);
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop",
"Polly - Import Scops from JSON"
" (Reads a .jscop file for each Scop)",
false, false)
namespace {
class JSONImporterPrinterLegacyPass final : public ScopPass { … };
char JSONImporterPrinterLegacyPass::ID = …;
}
Pass *polly::createJSONImporterPrinterLegacyPass(llvm::raw_ostream &OS) { … }
INITIALIZE_PASS_BEGIN(JSONImporterPrinterLegacyPass, "polly-print-import-jscop",
"Polly - Print Scop import result", false, false)
INITIALIZE_PASS_DEPENDENCY(JSONImporter)
INITIALIZE_PASS_END(JSONImporterPrinterLegacyPass, "polly-print-import-jscop",
"Polly - Print Scop import result", false, false)