[polly] r276245 - JScop: Factor out importContext [NFC]

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 23:56:31 PDT 2016


Author: grosser
Date: Thu Jul 21 01:56:31 2016
New Revision: 276245

URL: http://llvm.org/viewvc/llvm-project?rev=276245&view=rev
Log:
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.

Modified:
    polly/trunk/lib/Exchange/JSONExporter.cpp

Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=276245&r1=276244&r2=276245&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Thu Jul 21 01:56:31 2016
@@ -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
 
 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;




More information about the llvm-commits mailing list