Polly 22.0.0git
JSONExporter.cpp File Reference
#include "polly/JSONExporter.h"
#include "polly/DependenceInfo.h"
#include "polly/Options.h"
#include "polly/ScopInfo.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

static cl::opt< bool > PollyPrintImportJscop ("polly-print-import-jscop", cl::desc("Polly - Print Scop import result"), cl::cat(PollyCategory))
 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.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "polly-import-jscop"

Definition at line 35 of file JSONExporter.cpp.

Typedef Documentation

◆ StatementToIslMapTy

Function Documentation

◆ areArraysEqual()

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

◆ exportArrays()

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 73 of file JSONExporter.cpp.

References polly::Array, and S.

Referenced by getJSON().

◆ exportScop()

void exportScop ( Scop & S)
static

Definition at line 150 of file JSONExporter.cpp.

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

Referenced by polly::runExportJSON().

◆ getFileName()

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

Definition at line 58 of file JSONExporter.cpp.

References S.

Referenced by exportScop(), and importScop().

◆ getJSON()

json::Value getJSON ( Scop & S)
static

Definition at line 104 of file JSONExporter.cpp.

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

Referenced by exportScop().

◆ importAccesses()

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 322 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, isl_set_free(), isl_set_has_equal_space(), isl_set_intersect(), isl_set_intersect_params(), isl_set_is_subset(), isl::manage(), and S.

Referenced by importScop().

◆ importArrays()

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 604 of file JSONExporter.cpp.

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

Referenced by importScop().

◆ importContext()

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 185 of file JSONExporter.cpp.

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

Referenced by importScop().

◆ importSchedule()

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 239 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(), isl::manage(), and S.

Referenced by importScop().

◆ importScop()

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 669 of file JSONExporter.cpp.

References getFileName(), importAccesses(), importArrays(), importContext(), importSchedule(), and S.

Referenced by polly::runImportJSON().

◆ parseTextType()

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 572 of file JSONExporter.cpp.

Referenced by importArrays().

◆ PollyPrintImportJscop()

cl::opt< bool > PollyPrintImportJscop ( "polly-print-import-jscop" ,
cl::desc("Polly - Print Scop import result") ,
cl::cat(PollyCategory)  )
static

References PollyCategory.

Referenced by polly::runImportJSON().

◆ STATISTIC()

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

References PollyCategory.