summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/include/polly/ScopInfo.h11
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp25
-rw-r--r--polly/lib/CodeGen/IslAst.cpp20
3 files changed, 41 insertions, 15 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 7e196912c6c..5dfbe4ec112 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -842,10 +842,17 @@ private:
/// group to ensure the SCoP is executed in an alias free environment.
MinMaxVectorPairVectorTy MinMaxAliasGroups;
+ /// @brief Scop constructor; used by static createFromTempScop
+ Scop(Region &R, ScalarEvolution &SE, isl_ctx *ctx, unsigned MaxLoopDepth);
+
+ /// @brief Initialize this ScopInfo using a TempScop object.
+ void initFromTempScop(TempScop &TempScop, LoopInfo &LI, ScopDetection &SD);
+
/// Create the static control part with a region, max loop depth of this
/// region and parameters used in this region.
- Scop(TempScop &TempScop, LoopInfo &LI, ScalarEvolution &SE, ScopDetection &SD,
- isl_ctx *ctx);
+ static Scop *createFromTempScop(TempScop &TempScop, LoopInfo &LI,
+ ScalarEvolution &SE, ScopDetection &SD,
+ isl_ctx *ctx);
/// @brief Check if a basic block is trivial.
///
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 28214685b59..3081f1a3c3f 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1664,19 +1664,20 @@ static unsigned getMaxLoopDepthInRegion(const Region &R, LoopInfo &LI,
return MaxLD - MinLD + 1;
}
-Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
- ScopDetection &SD, isl_ctx *Context)
- : SE(&ScalarEvolution), R(tempScop.getMaxRegion()), IsOptimized(false),
- MaxLoopDepth(getMaxLoopDepthInRegion(tempScop.getMaxRegion(), LI, SD)) {
- IslCtx = Context;
+Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, isl_ctx *Context,
+ unsigned MaxLoopDepth)
+ : SE(&ScalarEvolution), R(R), IsOptimized(false),
+ MaxLoopDepth(MaxLoopDepth), IslCtx(Context) {}
+void Scop::initFromTempScop(TempScop &TempScop, LoopInfo &LI,
+ ScopDetection &SD) {
buildContext();
SmallVector<Loop *, 8> NestLoops;
// Build the iteration domain, access functions and schedule functions
// traversing the region tree.
- Schedule = buildScop(tempScop, getRegion(), NestLoops, LI, SD);
+ Schedule = buildScop(TempScop, getRegion(), NestLoops, LI, SD);
if (!Schedule)
Schedule = isl_schedule_empty(getParamSpace());
@@ -1687,6 +1688,16 @@ Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
assert(NestLoops.empty() && "NestLoops not empty at top level!");
}
+Scop *Scop::createFromTempScop(TempScop &TempScop, LoopInfo &LI,
+ ScalarEvolution &SE, ScopDetection &SD,
+ isl_ctx *ctx) {
+ auto &R = TempScop.getMaxRegion();
+ auto MaxLoopDepth = getMaxLoopDepthInRegion(R, LI, SD);
+ auto S = new Scop(R, SE, ctx, MaxLoopDepth);
+ S->initFromTempScop(TempScop, LI, SD);
+ return S;
+}
+
Scop::~Scop() {
isl_set_free(Context);
isl_set_free(AssumedContext);
@@ -2165,7 +2176,7 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) {
return false;
}
- scop = new Scop(*tempScop, LI, SE, SD, ctx);
+ scop = Scop::createFromTempScop(*tempScop, LI, SE, SD, ctx);
DEBUG(scop->print(dbgs()));
diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp
index 12effd1eb91..3c17517c923 100644
--- a/polly/lib/CodeGen/IslAst.cpp
+++ b/polly/lib/CodeGen/IslAst.cpp
@@ -71,8 +71,7 @@ static cl::opt<bool> NoEarlyExit(
namespace polly {
class IslAst {
public:
- IslAst(Scop *Scop, const Dependences &D);
-
+ static IslAst *create(Scop *Scop, const Dependences &D);
~IslAst();
/// Print a source code representation of the program.
@@ -88,6 +87,9 @@ private:
isl_ast_node *Root;
isl_ast_expr *RunCondition;
+ IslAst(Scop *Scop);
+ void init(const Dependences &D);
+
void buildRunCondition(__isl_keep isl_ast_build *Build);
};
} // End namespace polly.
@@ -372,14 +374,14 @@ static bool benefitsFromPolly(Scop *Scop, bool PerformParallelTest) {
return true;
}
-IslAst::IslAst(Scop *Scop, const Dependences &D)
- : S(Scop), Root(nullptr), RunCondition(nullptr) {
+IslAst::IslAst(Scop *Scop) : S(Scop), Root(nullptr), RunCondition(nullptr) {}
+void IslAst::init(const Dependences &D) {
bool PerformParallelTest = PollyParallel || DetectParallel ||
PollyVectorizerChoice != VECTORIZER_NONE;
// Skip AST and code generation if there was no benefit achieved.
- if (!benefitsFromPolly(Scop, PerformParallelTest))
+ if (!benefitsFromPolly(S, PerformParallelTest))
return;
isl_ctx *Ctx = S->getIslCtx();
@@ -411,6 +413,12 @@ IslAst::IslAst(Scop *Scop, const Dependences &D)
isl_ast_build_free(Build);
}
+IslAst *IslAst::create(Scop *Scop, const Dependences &D) {
+ auto Ast = new IslAst(Scop);
+ Ast->init(D);
+ return Ast;
+}
+
IslAst::~IslAst() {
isl_ast_node_free(Root);
isl_ast_expr_free(RunCondition);
@@ -436,7 +444,7 @@ bool IslAstInfo::runOnScop(Scop &Scop) {
const Dependences &D = getAnalysis<DependenceInfo>().getDependences();
- Ast = new IslAst(&Scop, D);
+ Ast = IslAst::create(&Scop, D);
DEBUG(printScop(dbgs(), Scop));
return false;
OpenPOWER on IntegriCloud