diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-05-29 09:29:44 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-05-29 09:29:44 +0000 |
commit | 084d8f7d4c937922f6d6397aff4f6a251144206e (patch) | |
tree | 2ad83f5a59e5b7ec945f5d2f50b58517b3a4fe03 /polly | |
parent | 400a4ac6586460f195c63e78c04ab1016882841d (diff) | |
download | bcm5719-llvm-084d8f7d4c937922f6d6397aff4f6a251144206e.tar.gz bcm5719-llvm-084d8f7d4c937922f6d6397aff4f6a251144206e.zip |
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.
llvm-svn: 157607
Diffstat (limited to 'polly')
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 33 | ||||
-rwxr-xr-x | polly/lib/Exchange/JSONExporter.cpp | 12 |
2 files changed, 29 insertions, 16 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 2c9486c5fc8..615ab363cd0 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -268,14 +268,12 @@ isl_map *MemoryAccess::getNewAccessRelation() const { } 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 @@ MemoryAccess::MemoryAccess(const IRAccess &Access, ScopStmt *Statement) { statement = Statement; BaseAddr = Access.getBase(); + setBaseName(); if (!Access.isAffine()) { Type = (Type == Read) ? Read : MayWrite; @@ -293,8 +292,6 @@ MemoryAccess::MemoryAccess(const IRAccess &Access, ScopStmt *Statement) { 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 @@ MemoryAccess::MemoryAccess(const IRAccess &Access, ScopStmt *Statement) { 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 @@ void ScopStmt::buildScattering(SmallVectorImpl<unsigned> &Scatter) { 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 @@ __isl_give isl_set *ScopStmt::buildDomain(TempScop &tempScop, 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; } diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index 0113e88cd8d..1e50b1870b1 100755 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -245,6 +245,13 @@ bool JSONImporter::runOnScop(Scop &scop) { 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 @@ bool JSONImporter::runOnScop(Scop &scop) { 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"; |