[llvm-commits] [polly] r157607 - in /polly/trunk/lib: Analysis/ScopInfo.cpp Exchange/JSONExporter.cpp

Tobias Grosser grosser at fim.uni-passau.de
Tue May 29 02:29:45 PDT 2012


Author: grosser
Date: Tue May 29 04:29:44 2012
New Revision: 157607

URL: http://llvm.org/viewvc/llvm-project?rev=157607&view=rev
Log:
ScopInfo: Store ScopStmt pointer in the domain

Store a pointer to each ScopStmt in the isl_id associated with the space of its
domain. This will later allow us to recover the statement during code
generation with isl.

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

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=157607&r1=157606&r2=157607&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue May 29 04:29:44 2012
@@ -268,14 +268,12 @@
 }
 
 isl_basic_map *MemoryAccess::createBasicAccessMap(ScopStmt *Statement) {
-  isl_space *Space = isl_space_alloc(Statement->getIslCtx(), 0,
-                                    Statement->getNumIterators(), 1);
-  setBaseName();
-
-  Space = isl_space_set_tuple_name(Space, isl_dim_out, getBaseName().c_str());
-  Space = isl_space_set_tuple_name(Space, isl_dim_in, Statement->getBaseName());
+  isl_space *Space = isl_space_set_alloc(Statement->getIslCtx(), 0, 1);
+  Space = isl_space_set_tuple_name(Space, isl_dim_set, getBaseName().c_str());
 
-  return isl_basic_map_universe(Space);
+  return isl_basic_map_from_domain_and_range(
+    isl_basic_set_universe(Statement->getDomainSpace()),
+    isl_basic_set_universe(Space));
 }
 
 MemoryAccess::MemoryAccess(const IRAccess &Access, ScopStmt *Statement) {
@@ -284,6 +282,7 @@
   statement = Statement;
 
   BaseAddr = Access.getBase();
+  setBaseName();
 
   if (!Access.isAffine()) {
     Type = (Type == Read) ? Read : MayWrite;
@@ -293,8 +292,6 @@
 
   isl_pw_aff *Affine = SCEVAffinator::getPwAff(Statement, Access.getOffset());
 
-  setBaseName();
-
   // Divide the access function by the size of the elements in the array.
   //
   // A stride one array access in C expressed as A[i] is expressed in LLVM-IR
@@ -309,8 +306,10 @@
   isl_int_clear(v);
 
   AccessRelation = isl_map_from_pw_aff(Affine);
-  AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_in,
-                                          Statement->getBaseName());
+  isl_space *Space = Statement->getDomainSpace();
+  AccessRelation = isl_map_set_tuple_id(AccessRelation, isl_dim_in,
+    isl_space_get_tuple_id(Space, isl_dim_set));
+  isl_space_free(Space);
   AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_out,
                                           getBaseName().c_str());
 }
@@ -461,12 +460,11 @@
   unsigned NbIterators = getNumIterators();
   unsigned NbScatteringDims = Parent.getMaxLoopDepth() * 2 + 1;
 
-  isl_space *Space = isl_space_alloc(getIslCtx(), 0, NbIterators,
-                                     NbScatteringDims);
+  isl_space *Space = isl_space_set_alloc(getIslCtx(), 0, NbScatteringDims);
   Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering");
-  Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName());
 
-  Scattering = isl_map_universe(Space);
+  Scattering = isl_map_from_domain_and_range(isl_set_universe(getDomainSpace()),
+                                             isl_set_universe(Space));
 
   // Loop dimensions.
   for (unsigned i = 0; i < NbIterators; ++i)
@@ -585,13 +583,16 @@
                                           const Region &CurRegion) {
   isl_space *Space;
   isl_set *Domain;
+  isl_id *Id;
 
   Space = isl_space_set_alloc(getIslCtx(), 0, getNumIterators());
 
+  Id = isl_id_alloc(getIslCtx(), getBaseName(), this);
+
   Domain = isl_set_universe(Space);
   Domain = addLoopBoundsToDomain(Domain, tempScop);
   Domain = addConditionsToDomain(Domain, tempScop, CurRegion);
-  Domain = isl_set_set_tuple_name(Domain, getBaseName());
+  Domain = isl_set_set_tuple_id(Domain, Id);
 
   return Domain;
 }

Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=157607&r1=157606&r2=157607&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Tue May 29 04:29:44 2012
@@ -245,6 +245,13 @@
   for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
     Json::Value schedule = jscop["statements"][index]["schedule"];
     isl_map *m = isl_map_read_from_str(S->getIslCtx(), schedule.asCString());
+    isl_space *Space = (*SI)->getDomainSpace();
+
+    // Copy the old tuple id. This is necessary to retain the user pointer,
+    // that stores the reference to the ScopStmt this scattering belongs to.
+    m = isl_map_set_tuple_id(m, isl_dim_in,
+                             isl_space_get_tuple_id(Space, isl_dim_set));
+    isl_space_free(Space);
     NewScattering[*SI] = m;
     index++;
   }
@@ -293,6 +300,11 @@
         newAccessMap = isl_map_set_dim_id(newAccessMap, isl_dim_param, i, id);
       }
 
+      // Copy the old tuple id. This is necessary to retain the user pointer,
+      // that stores the reference to the ScopStmt this access belongs to.
+      isl_id *Id = isl_map_get_tuple_id(currentAccessMap, isl_dim_in);
+      newAccessMap = isl_map_set_tuple_id(newAccessMap, isl_dim_in, Id);
+
       if (!isl_map_has_equal_space(currentAccessMap, newAccessMap)) {
         errs() << "JScop file contains access function with incompatible "
                << "dimensions\n";





More information about the llvm-commits mailing list