diff options
| author | Tobias Grosser <tobias@grosser.es> | 2016-07-21 06:56:31 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2016-07-21 06:56:31 +0000 |
| commit | dbe34f7c58b694380a505f63094673a35859df5e (patch) | |
| tree | 04f5ab87655a72a4d9ec76337a013c8b415a1a45 | |
| parent | c602d3bc8438533e06787b1d8d2474648d265b61 (diff) | |
| download | bcm5719-llvm-dbe34f7c58b694380a505f63094673a35859df5e.tar.gz bcm5719-llvm-dbe34f7c58b694380a505f63094673a35859df5e.zip | |
JScop: Factor out importContext [NFC]
This makes the structure of the code clearer and reduces the size of runOnScop.
We also adjust the coding style to the latest LLVM style guide.
llvm-svn: 276245
| -rw-r--r-- | polly/lib/Exchange/JSONExporter.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index 6dd2749d72e..bc680fbc9a8 100644 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -76,6 +76,14 @@ struct JSONImporter : public ScopPass { std::vector<std::string> newAccessStrings; explicit JSONImporter() : ScopPass(ID) {} + /// 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); + /// Import a new schedule from JScop. /// /// ... and verify that the new schedule does preserve existing data @@ -209,6 +217,21 @@ void JSONImporter::printScop(raw_ostream &OS, Scop &S) const { typedef Dependences::StatementToIslMapTy StatementToIslMapTy; +bool JSONImporter::importContext(Scop &S, Json::Value &JScop) { + isl_set *OldContext = S.getContext(); + isl_set *NewContext = + isl_set_read_from_str(S.getIslCtx(), JScop["context"].asCString()); + + for (unsigned i = 0; i < isl_set_dim(OldContext, isl_dim_param); i++) { + 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; +} + bool JSONImporter::importSchedule(Scop &S, Json::Value &JScop, const Dependences &D) { StatementToIslMapTy NewSchedule; @@ -282,19 +305,12 @@ bool JSONImporter::runOnScop(Scop &S) { return false; } - isl_set *OldContext = S.getContext(); - isl_set *NewContext = - isl_set_read_from_str(S.getIslCtx(), jscop["context"].asCString()); + bool Success = importContext(S, jscop); - for (unsigned i = 0; i < isl_set_dim(OldContext, isl_dim_param); i++) { - 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); + if (!Success) + return false; - bool Success = importSchedule(S, jscop, D); + Success = importSchedule(S, jscop, D); if (!Success) return false; |

