Skip to content

Commit fdc61bc

Browse files
[NFC][ScopBuilder] Move addUserContext to ScopBuilder
Scope of changes: 1) Moved addUserContext to ScopBuilder. 2) Moved command line option UserContextStr to ScopBuilder. Differential Revision: https://reviews.llvm.org/D63740 llvm-svn: 366266
1 parent ffca322 commit fdc61bc

File tree

4 files changed

+48
-47
lines changed

4 files changed

+48
-47
lines changed

polly/include/polly/ScopBuilder.h

+3
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ class ScopBuilder {
376376
BasicBlock *IncomingBlock, Value *IncomingValue,
377377
bool IsExitBlock);
378378

379+
/// Add user provided parameter constraints to context (command line).
380+
void addUserContext();
381+
379382
/// Add all recorded assumptions to the assumed context.
380383
void addRecordedAssumptions();
381384

polly/include/polly/ScopInfo.h

-3
Original file line numberDiff line numberDiff line change
@@ -2044,9 +2044,6 @@ class Scop {
20442044
void addUserAssumptions(AssumptionCache &AC, DominatorTree &DT, LoopInfo &LI,
20452045
DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
20462046

2047-
/// Add user provided parameter constraints to context (command line).
2048-
void addUserContext();
2049-
20502047
/// Add the bounds of the parameters to the context.
20512048
void addParameterBounds();
20522049

polly/lib/Analysis/ScopBuilder.cpp

+45-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ static cl::opt<bool> UnprofitableScalarAccs(
114114
cl::desc("Count statements with scalar accesses as not optimizable"),
115115
cl::Hidden, cl::init(false), cl::cat(PollyCategory));
116116

117+
static cl::opt<std::string> UserContextStr(
118+
"polly-context", cl::value_desc("isl parameter set"),
119+
cl::desc("Provide additional constraints on the context parameters"),
120+
cl::init(""), cl::cat(PollyCategory));
121+
117122
static cl::opt<bool> DetectFortranArrays(
118123
"polly-detect-fortran-arrays",
119124
cl::desc("Detect Fortran arrays and use this for code generation"),
@@ -1454,6 +1459,45 @@ bool ScopBuilder::hasNonHoistableBasePtrInScop(MemoryAccess *MA,
14541459
return false;
14551460
}
14561461

1462+
void ScopBuilder::addUserContext() {
1463+
if (UserContextStr.empty())
1464+
return;
1465+
1466+
isl::set UserContext = isl::set(scop->getIslCtx(), UserContextStr.c_str());
1467+
isl::space Space = scop->getParamSpace();
1468+
if (Space.dim(isl::dim::param) != UserContext.dim(isl::dim::param)) {
1469+
std::string SpaceStr = Space.to_str();
1470+
errs() << "Error: the context provided in -polly-context has not the same "
1471+
<< "number of dimensions than the computed context. Due to this "
1472+
<< "mismatch, the -polly-context option is ignored. Please provide "
1473+
<< "the context in the parameter space: " << SpaceStr << ".\n";
1474+
return;
1475+
}
1476+
1477+
for (unsigned i = 0; i < Space.dim(isl::dim::param); i++) {
1478+
std::string NameContext =
1479+
scop->getContext().get_dim_name(isl::dim::param, i);
1480+
std::string NameUserContext = UserContext.get_dim_name(isl::dim::param, i);
1481+
1482+
if (NameContext != NameUserContext) {
1483+
std::string SpaceStr = Space.to_str();
1484+
errs() << "Error: the name of dimension " << i
1485+
<< " provided in -polly-context "
1486+
<< "is '" << NameUserContext << "', but the name in the computed "
1487+
<< "context is '" << NameContext
1488+
<< "'. Due to this name mismatch, "
1489+
<< "the -polly-context option is ignored. Please provide "
1490+
<< "the context in the parameter space: " << SpaceStr << ".\n";
1491+
return;
1492+
}
1493+
1494+
UserContext = UserContext.set_dim_id(isl::dim::param, i,
1495+
Space.get_dim_id(isl::dim::param, i));
1496+
}
1497+
isl::set newContext = scop->getContext().intersect(UserContext);
1498+
scop->setContext(newContext);
1499+
}
1500+
14571501
isl::set ScopBuilder::getNonHoistableCtx(MemoryAccess *Access,
14581502
isl::union_map Writes) {
14591503
// TODO: Loads that are not loop carried, hence are in a statement with
@@ -2326,7 +2370,7 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {
23262370
scop->finalizeAccesses();
23272371

23282372
scop->realignParams();
2329-
scop->addUserContext();
2373+
addUserContext();
23302374

23312375
// After the context was fully constructed, thus all our knowledge about
23322376
// the parameters is in there, we add all recorded assumptions to the

polly/lib/Analysis/ScopInfo.cpp

-43
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ static cl::opt<bool> PollyRemarksMinimal(
122122
cl::desc("Do not emit remarks about assumptions that are known"),
123123
cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory));
124124

125-
static cl::opt<std::string> UserContextStr(
126-
"polly-context", cl::value_desc("isl parameter set"),
127-
cl::desc("Provide additional constraints on the context parameters"),
128-
cl::init(""), cl::cat(PollyCategory));
129-
130125
static cl::opt<bool>
131126
IslOnErrorAbort("polly-on-isl-error-abort",
132127
cl::desc("Abort if an isl error is encountered"),
@@ -2017,44 +2012,6 @@ void Scop::addUserAssumptions(
20172012
}
20182013
}
20192014

2020-
void Scop::addUserContext() {
2021-
if (UserContextStr.empty())
2022-
return;
2023-
2024-
isl::set UserContext = isl::set(getIslCtx(), UserContextStr.c_str());
2025-
isl::space Space = getParamSpace();
2026-
if (Space.dim(isl::dim::param) != UserContext.dim(isl::dim::param)) {
2027-
std::string SpaceStr = Space.to_str();
2028-
errs() << "Error: the context provided in -polly-context has not the same "
2029-
<< "number of dimensions than the computed context. Due to this "
2030-
<< "mismatch, the -polly-context option is ignored. Please provide "
2031-
<< "the context in the parameter space: " << SpaceStr << ".\n";
2032-
return;
2033-
}
2034-
2035-
for (unsigned i = 0; i < Space.dim(isl::dim::param); i++) {
2036-
std::string NameContext = Context.get_dim_name(isl::dim::param, i);
2037-
std::string NameUserContext = UserContext.get_dim_name(isl::dim::param, i);
2038-
2039-
if (NameContext != NameUserContext) {
2040-
std::string SpaceStr = Space.to_str();
2041-
errs() << "Error: the name of dimension " << i
2042-
<< " provided in -polly-context "
2043-
<< "is '" << NameUserContext << "', but the name in the computed "
2044-
<< "context is '" << NameContext
2045-
<< "'. Due to this name mismatch, "
2046-
<< "the -polly-context option is ignored. Please provide "
2047-
<< "the context in the parameter space: " << SpaceStr << ".\n";
2048-
return;
2049-
}
2050-
2051-
UserContext = UserContext.set_dim_id(isl::dim::param, i,
2052-
Space.get_dim_id(isl::dim::param, i));
2053-
}
2054-
2055-
Context = Context.intersect(UserContext);
2056-
}
2057-
20582015
void Scop::buildContext() {
20592016
isl::space Space = isl::space::params_alloc(getIslCtx(), 0);
20602017
Context = isl::set::universe(Space);

0 commit comments

Comments
 (0)