@@ -114,6 +114,11 @@ static cl::opt<bool> UnprofitableScalarAccs(
114
114
cl::desc (" Count statements with scalar accesses as not optimizable" ),
115
115
cl::Hidden, cl::init(false ), cl::cat(PollyCategory));
116
116
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
+
117
122
static cl::opt<bool > DetectFortranArrays (
118
123
" polly-detect-fortran-arrays" ,
119
124
cl::desc (" Detect Fortran arrays and use this for code generation" ),
@@ -1454,6 +1459,45 @@ bool ScopBuilder::hasNonHoistableBasePtrInScop(MemoryAccess *MA,
1454
1459
return false ;
1455
1460
}
1456
1461
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
+
1457
1501
isl::set ScopBuilder::getNonHoistableCtx (MemoryAccess *Access,
1458
1502
isl::union_map Writes) {
1459
1503
// TODO: Loads that are not loop carried, hence are in a statement with
@@ -2326,7 +2370,7 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {
2326
2370
scop->finalizeAccesses ();
2327
2371
2328
2372
scop->realignParams ();
2329
- scop-> addUserContext ();
2373
+ addUserContext ();
2330
2374
2331
2375
// After the context was fully constructed, thus all our knowledge about
2332
2376
// the parameters is in there, we add all recorded assumptions to the
0 commit comments