Polly 20.0.0git
Macros | Typedefs | Functions | Variables
JSONExporter.cpp File Reference
#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>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "polly-import-jscop"
 

Typedefs

typedef Dependences::StatementToIslMapTy StatementToIslMapTy
 

Functions

 STATISTIC (NewAccessMapFound, "Number of updated access functions")
 
static std::string getFileName (Scop &S, StringRef Suffix="")
 
static json::Array exportArrays (const Scop &S)
 Export all arrays from the Scop.
 
static json::Value getJSON (Scop &S)
 
static void exportScop (Scop &S)
 
static bool importContext (Scop &S, const json::Object &JScop)
 Import a new context from JScop.
 
static bool importSchedule (Scop &S, const json::Object &JScop, const Dependences &D)
 Import a new schedule from JScop.
 
static bool importAccesses (Scop &S, const json::Object &JScop, const DataLayout &DL, std::vector< std::string > *NewAccessStrings=nullptr)
 Import new memory accesses from JScop.
 
static bool areArraysEqual (ScopArrayInfo *SAI, const json::Object &Array)
 Check whether SAI and Array represent the same array.
 
static Type * parseTextType (const std::string &TypeTextRepresentation, LLVMContext &LLVMContext)
 Get the accepted primitive type from its textual representation TypeTextRepresentation.
 
static bool importArrays (Scop &S, const json::Object &JScop)
 Import new arrays from JScop.
 
static bool importScop (Scop &S, const Dependences &D, const DataLayout &DL, std::vector< std::string > *NewAccessStrings=nullptr)
 Import a Scop from a JSCOP file.
 
 INITIALIZE_PASS_BEGIN (JSONExporter, "polly-export-jscop", "Polly - Export Scops as JSON" " (Writes a .jscop file for each Scop)", false, false)
 
 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 Polly Import Scops from JSON (Reads a .jscop file for each Scop)"
 
 INITIALIZE_PASS_END (JSONImporter, "polly-import-jscop", "Polly - Import Scops from JSON" " (Reads a .jscop file for each Scop)", false, false) namespace
 
 INITIALIZE_PASS_BEGIN (JSONImporterPrinterLegacyPass, "polly-print-import-jscop", "Polly - Print Scop import result", false, false) INITIALIZE_PASS_END(JSONImporterPrinterLegacyPass
 

Variables

polly import jscop
 
polly import Polly Import Scops from false
 
polly print import Polly Print Scop import result
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "polly-import-jscop"

Definition at line 37 of file JSONExporter.cpp.

Typedef Documentation

◆ StatementToIslMapTy

Definition at line 204 of file JSONExporter.cpp.

Function Documentation

◆ areArraysEqual()

static bool areArraysEqual ( ScopArrayInfo SAI,
const json::Object &  Array 
)
static

◆ exportArrays()

static json::Array exportArrays ( const Scop S)
static

Export all arrays from the Scop.

Parameters
SThe Scop containing the arrays.
Returns
Json::Value containing the arrays.

Definition at line 100 of file JSONExporter.cpp.

References polly::Array.

Referenced by getJSON().

◆ exportScop()

static void exportScop ( Scop S)
static

Definition at line 177 of file JSONExporter.cpp.

References getFileName(), getJSON(), and jscop.

Referenced by polly::JSONExportPass::run().

◆ getFileName()

static std::string getFileName ( Scop S,
StringRef  Suffix = "" 
)
static

Definition at line 85 of file JSONExporter.cpp.

Referenced by exportScop(), and importScop().

◆ getJSON()

static json::Value getJSON ( Scop S)
static

Definition at line 131 of file JSONExporter.cpp.

References exportArrays(), and polly::getDebugLocation().

Referenced by exportScop().

◆ importAccesses()

static bool importAccesses ( Scop S,
const json::Object &  JScop,
const DataLayout &  DL,
std::vector< std::string > *  NewAccessStrings = nullptr 
)
static

Import new memory accesses from JScop.

Parameters
SThe scop to update.
JScopThe JScop file describing the new schedule.
DLThe data layout to assume.
NewAccessStringsoptionally record the imported access strings
Returns
True if the import succeeded, otherwise False.

Definition at line 349 of file JSONExporter.cpp.

References assert, polly::ScopArrayInfo::getFromId(), isl_bool_false, isl_dim_in, isl_dim_out, isl_dim_param, isl_id_free(), isl_id_get_name(), isl_map_copy(), isl_map_dim(), isl_map_domain(), isl_map_free(), isl_map_get_dim_id(), isl_map_get_tuple_id(), isl_map_is_equal(), isl_map_range(), isl_map_read_from_str(), isl_map_set_dim_id(), isl_map_set_tuple_id(), isl_set_free(), isl_set_has_equal_space(), isl_set_intersect(), isl_set_intersect_params(), isl_set_is_subset(), and isl::manage().

Referenced by importScop().

◆ importArrays()

static bool importArrays ( Scop S,
const json::Object &  JScop 
)
static

Import new arrays from JScop.

Parameters
SThe scop to update.
JScopThe JScop file describing new arrays.
Returns
True if the import succeeded, otherwise False.

Definition at line 631 of file JSONExporter.cpp.

References areArraysEqual(), polly::Array, parseTextType(), and str.

Referenced by importScop().

◆ importContext()

static bool importContext ( Scop S,
const json::Object &  JScop 
)
static

Import a new context from JScop.

Parameters
SThe scop to update.
JScopThe JScop file describing the new schedule.
Returns
True if the import succeeded, otherwise False.

Definition at line 212 of file JSONExporter.cpp.

References isl::set::dim(), isl::set::get_dim_id(), isl::set::is_null(), isl::set::is_params(), isl::param, isl::set::set_dim_id(), and unsignedFromIslSize().

Referenced by importScop().

◆ importSchedule()

static bool importSchedule ( Scop S,
const json::Object &  JScop,
const Dependences D 
)
static

Import a new schedule from JScop.

... and verify that the new schedule does preserve existing data dependences.

Parameters
SThe scop to update.
JScopThe JScop file describing the new schedule.
DThe data dependences of the S.
Returns
True if the import succeeded, otherwise False.

Definition at line 266 of file JSONExporter.cpp.

References assert, isl::union_map::empty(), isl_dim_in, isl_dim_param, isl_dim_set, isl_map_read_from_str(), isl_map_set_dim_id(), isl_map_set_tuple_id(), isl_space_dim(), isl_space_free(), isl_space_get_dim_id(), isl_space_get_tuple_id(), polly::Dependences::isValidSchedule(), and isl::manage().

Referenced by importScop().

◆ importScop()

static bool importScop ( Scop S,
const Dependences D,
const DataLayout &  DL,
std::vector< std::string > *  NewAccessStrings = nullptr 
)
static

Import a Scop from a JSCOP file.

Parameters
SThe scop to be modified
DDependence Info
DLThe DataLayout of the function
NewAccessStringsOptionally record the imported access strings
Returns
true on success, false otherwise. Beware that if this returns false, the Scop may still have been modified. In this case the Scop contains invalid information.

Definition at line 696 of file JSONExporter.cpp.

References getFileName(), importAccesses(), importArrays(), importContext(), importSchedule(), jscop, and result.

Referenced by polly::JSONImportPass::run().

◆ INITIALIZE_PASS_BEGIN() [1/2]

INITIALIZE_PASS_BEGIN ( JSONExporter  ,
"polly-export-jscop"  ,
"Polly - Export Scops as JSON" " (Writes a .jscop file for each Scop)"  ,
false  ,
false   
)

◆ INITIALIZE_PASS_BEGIN() [2/2]

INITIALIZE_PASS_BEGIN ( JSONImporterPrinterLegacyPass  ,
"polly-print-import-jscop"  ,
"Polly - Print Scop import result"  ,
false  ,
false   
)

◆ INITIALIZE_PASS_END() [1/2]

INITIALIZE_PASS_END ( JSONExporter  ,
"polly-export-jscop"  ,
"Polly - Export Scops as JSON" " (Writes a .jscop file for each Scop)"  ,
false  ,
false   
)

◆ INITIALIZE_PASS_END() [2/2]

INITIALIZE_PASS_END ( JSONImporter  ,
"polly-import-jscop"  ,
"Polly - Import Scops from JSON" " (Reads a .jscop file for each Scop)"  ,
false  ,
false   
)

Print result from JSONImporter.

Definition at line 832 of file JSONExporter.cpp.

References polly::ScopPass::getAnalysisUsage().

◆ JSON()

polly import Polly Import Scops from JSON ( Reads a .jscop file for each  Scop)

◆ parseTextType()

static Type * parseTextType ( const std::string &  TypeTextRepresentation,
LLVMContext &  LLVMContext 
)
static

Get the accepted primitive type from its textual representation TypeTextRepresentation.

Parameters
TypeTextRepresentationThe textual representation of the type.
Returns
The pointer to the primitive type, if this type is accepted or nullptr otherwise.

Definition at line 599 of file JSONExporter.cpp.

Referenced by importArrays().

◆ STATISTIC()

STATISTIC ( NewAccessMapFound  ,
"Number of updated access functions"   
)

Variable Documentation

◆ false

polly print import Polly Print Scop import false

Definition at line 830 of file JSONExporter.cpp.

◆ jscop

polly print import jscop

Definition at line 827 of file JSONExporter.cpp.

Referenced by exportScop(), and importScop().

◆ result

polly print import Polly Print Scop import result