Changeset View
Changeset View
Standalone View
Standalone View
lib/Exchange/JSONExporter.cpp
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
typedef Dependences::StatementToIslMapTy StatementToIslMapTy; | typedef Dependences::StatementToIslMapTy StatementToIslMapTy; | ||||
bool JSONImporter::runOnScop(Scop &scop) { | bool JSONImporter::runOnScop(Scop &scop) { | ||||
S = &scop; | S = &scop; | ||||
Region &R = S->getRegion(); | Region &R = S->getRegion(); | ||||
Dependences *D = &getAnalysis<Dependences>(); | Dependences *D = &getAnalysis<Dependences>(); | ||||
const DataLayout &DL = getAnalysis<DataLayoutPass>().getDataLayout(); | |||||
std::string FileName = ImportDir + "/" + getFileName(S); | std::string FileName = ImportDir + "/" + getFileName(S); | ||||
std::string FunctionName = R.getEntry()->getParent()->getName(); | std::string FunctionName = R.getEntry()->getParent()->getName(); | ||||
errs() << "Reading JScop '" << R.getNameStr() << "' in function '" | errs() << "Reading JScop '" << R.getNameStr() << "' in function '" | ||||
<< FunctionName << "' from '" << FileName << "'.\n"; | << FunctionName << "' from '" << FileName << "'.\n"; | ||||
ErrorOr<std::unique_ptr<MemoryBuffer>> result = | ErrorOr<std::unique_ptr<MemoryBuffer>> result = | ||||
MemoryBuffer::getFile(FileName); | MemoryBuffer::getFile(FileName); | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | for (MemoryAccess *MA : *Stmt) { | ||||
isl_map_free(newAccessMap); | isl_map_free(newAccessMap); | ||||
return false; | return false; | ||||
} | } | ||||
isl_id *OutId = isl_map_get_tuple_id(currentAccessMap, isl_dim_out); | isl_id *OutId = isl_map_get_tuple_id(currentAccessMap, isl_dim_out); | ||||
newAccessMap = isl_map_set_tuple_id(newAccessMap, isl_dim_out, OutId); | newAccessMap = isl_map_set_tuple_id(newAccessMap, isl_dim_out, OutId); | ||||
// We keep the old alignment, thus we cannot allow accesses to memory | // We keep the old alignment, thus we cannot allow accesses to memory | ||||
// locations that were not accessed before. | // 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 = | |||||
DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment(); | |||||
} else if (StoreInst *StoreI = | |||||
dyn_cast<StoreInst>(MA->getAccessInstruction())) { | |||||
SpecialAlignment = | |||||
DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) != | |||||
StoreI->getAlignment(); | |||||
} | |||||
if (SpecialAlignment) { | |||||
isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap)); | isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap)); | ||||
isl_set *currentAccessSet = isl_map_range(isl_map_copy(currentAccessMap)); | isl_set *currentAccessSet = | ||||
isl_map_range(isl_map_copy(currentAccessMap)); | |||||
bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet); | bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet); | ||||
isl_set_free(newAccessSet); | isl_set_free(newAccessSet); | ||||
isl_set_free(currentAccessSet); | isl_set_free(currentAccessSet); | ||||
if (!isSubset) { | if (!isSubset) { | ||||
errs() << "JScop file changes the accessed memory\n"; | errs() << "JScop file changes the accessed memory\n"; | ||||
isl_map_free(currentAccessMap); | isl_map_free(currentAccessMap); | ||||
isl_map_free(newAccessMap); | isl_map_free(newAccessMap); | ||||
return false; | return false; | ||||
} | } | ||||
} | |||||
// We need to copy the isl_ids for the parameter dimensions to the new | // We need to copy the isl_ids for the parameter dimensions to the new | ||||
// map. Without doing this the current map would have different | // map. Without doing this the current map would have different | ||||
// ids then the new one, even though both are named identically. | // ids then the new one, even though both are named identically. | ||||
for (unsigned i = 0; i < isl_map_dim(currentAccessMap, isl_dim_param); | for (unsigned i = 0; i < isl_map_dim(currentAccessMap, isl_dim_param); | ||||
i++) { | i++) { | ||||
isl_id *id = isl_map_get_dim_id(currentAccessMap, isl_dim_param, i); | 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); | newAccessMap = isl_map_set_dim_id(newAccessMap, isl_dim_param, i, id); | ||||
Show All 32 Lines | bool JSONImporter::runOnScop(Scop &scop) { | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const { | void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const { | ||||
ScopPass::getAnalysisUsage(AU); | ScopPass::getAnalysisUsage(AU); | ||||
AU.addRequired<Dependences>(); | AU.addRequired<Dependences>(); | ||||
AU.addRequired<DataLayoutPass>(); | |||||
} | } | ||||
Pass *polly::createJSONImporterPass() { return new JSONImporter(); } | Pass *polly::createJSONImporterPass() { return new JSONImporter(); } | ||||
INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop", | INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop", | ||||
"Polly - Export Scops as JSON" | "Polly - Export Scops as JSON" | ||||
" (Writes a .jscop file for each Scop)", | " (Writes a .jscop file for each Scop)", | ||||
false, false); | false, false); | ||||
INITIALIZE_PASS_DEPENDENCY(Dependences) | INITIALIZE_PASS_DEPENDENCY(Dependences) | ||||
INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop", | INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop", | ||||
"Polly - Export Scops as JSON" | "Polly - Export Scops as JSON" | ||||
" (Writes a .jscop file for each Scop)", | " (Writes a .jscop file for each Scop)", | ||||
false, false) | false, false) | ||||
INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop", | INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop", | ||||
"Polly - Import Scops from JSON" | "Polly - Import Scops from JSON" | ||||
" (Reads a .jscop file for each Scop)", | " (Reads a .jscop file for each Scop)", | ||||
false, false); | false, false); | ||||
INITIALIZE_PASS_DEPENDENCY(Dependences) | INITIALIZE_PASS_DEPENDENCY(Dependences) | ||||
INITIALIZE_PASS_DEPENDENCY(DataLayoutPass) | |||||
INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop", | INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop", | ||||
"Polly - Import Scops from JSON" | "Polly - Import Scops from JSON" | ||||
" (Reads a .jscop file for each Scop)", | " (Reads a .jscop file for each Scop)", | ||||
false, false) | false, false) |