summaryrefslogtreecommitdiffstats
path: root/polly
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2018-01-18 15:15:38 +0000
committerMichael Kruse <llvm@meinersbur.de>2018-01-18 15:15:38 +0000
commitd6e2208671c779f9b55ab888c18d803090ea08b7 (patch)
tree06fead053dee5d6a631eccd591135afceed1d503 /polly
parent768efb5379178d094feeae0eec55c6a40170d070 (diff)
downloadbcm5719-llvm-d6e2208671c779f9b55ab888c18d803090ea08b7.tar.gz
bcm5719-llvm-d6e2208671c779f9b55ab888c18d803090ea08b7.zip
[ScopInfo] Pass name to ScopStmt ctor. NFC.
This will give control of the statement's name to the caller. Required to give -polly-stmt-granularity=scalar-indep more control over the name of the generated statement in a follow-up commit. llvm-svn: 322851
Diffstat (limited to 'polly')
-rw-r--r--polly/include/polly/ScopInfo.h15
-rw-r--r--polly/lib/Analysis/ScopBuilder.cpp35
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp35
3 files changed, 53 insertions, 32 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 248e5f90342..dadaa300218 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -1195,8 +1195,8 @@ class ScopStmt {
public:
/// Create the ScopStmt from a BasicBlock.
- ScopStmt(Scop &parent, BasicBlock &bb, Loop *SurroundingLoop,
- std::vector<Instruction *> Instructions, int Count);
+ ScopStmt(Scop &parent, BasicBlock &bb, StringRef Name, Loop *SurroundingLoop,
+ std::vector<Instruction *> Instructions);
/// Create an overapproximating ScopStmt for the region @p R.
///
@@ -1206,7 +1206,7 @@ public:
/// blocks for now. We currently do not allow
/// to modify the instructions of blocks later
/// in the region statement.
- ScopStmt(Scop &parent, Region &R, Loop *SurroundingLoop,
+ ScopStmt(Scop &parent, Region &R, StringRef Name, Loop *SurroundingLoop,
std::vector<Instruction *> EntryBlockInstructions);
/// Create a copy statement.
@@ -2197,11 +2197,11 @@ private:
/// and map.
///
/// @param BB The basic block we build the statement for.
+ /// @param Name The name of the new statement.
/// @param SurroundingLoop The loop the created statement is contained in.
/// @param Instructions The instructions in the statement.
- /// @param Count The index of the created statement in @p BB.
- void addScopStmt(BasicBlock *BB, Loop *SurroundingLoop,
- std::vector<Instruction *> Instructions, int Count);
+ void addScopStmt(BasicBlock *BB, StringRef Name, Loop *SurroundingLoop,
+ std::vector<Instruction *> Instructions);
/// Create a new SCoP statement for @p R.
///
@@ -2209,11 +2209,12 @@ private:
/// and map.
///
/// @param R The region we build the statement for.
+ /// @param Name The name of the new statement.
/// @param SurroundingLoop The loop the created statement is contained
/// in.
/// @param EntryBlockInstructions The (interesting) instructions in the
/// entry block of the region statement.
- void addScopStmt(Region *R, Loop *SurroundingLoop,
+ void addScopStmt(Region *R, StringRef Name, Loop *SurroundingLoop,
std::vector<Instruction *> EntryBlockInstructions);
/// Update access dimensionalities.
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index 3c7f67be0ec..3274aa2a1b1 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -19,6 +19,7 @@
#include "polly/ScopDetection.h"
#include "polly/ScopDetectionDiagnostic.h"
#include "polly/ScopInfo.h"
+#include "polly/Support/GICHelper.h"
#include "polly/Support/SCEVValidator.h"
#include "polly/Support/ScopHelper.h"
#include "polly/Support/VirtualInstruction.h"
@@ -688,6 +689,28 @@ bool ScopBuilder::shouldModelInst(Instruction *Inst, Loop *L) {
!canSynthesize(Inst, *scop, &SE, L);
}
+/// Generate a name for a statement.
+///
+/// @param S The parent SCoP.
+/// @param BB The basic block the statement will represent.
+/// @param Count The index of the created statement in @p BB.
+static std::string makeStmtName(Scop *S, BasicBlock *BB, int Count) {
+ std::string Suffix = "";
+ if (Count != 0)
+ Suffix += std::to_string(Count);
+ return getIslCompatibleName("Stmt", BB, S->getNextStmtIdx(), Suffix,
+ UseInstructionNames);
+}
+
+/// Generate a name for a statement that represents a non-affine subregion.
+///
+/// @param S The parent SCoP.
+/// @param R The region the statement will represent.
+static std::string makeStmtName(Scop *S, Region *R) {
+ return getIslCompatibleName("Stmt", R->getNameStr(), S->getNextStmtIdx(), "",
+ UseInstructionNames);
+}
+
void ScopBuilder::buildSequentialBlockStmts(BasicBlock *BB, bool SplitOnStore) {
Loop *SurroundingLoop = LI.getLoopFor(BB);
@@ -698,13 +721,15 @@ void ScopBuilder::buildSequentialBlockStmts(BasicBlock *BB, bool SplitOnStore) {
Instructions.push_back(&Inst);
if (Inst.getMetadata("polly_split_after") ||
(SplitOnStore && isa<StoreInst>(Inst))) {
- scop->addScopStmt(BB, SurroundingLoop, Instructions, Count);
+ std::string Name = makeStmtName(scop.get(), BB, Count);
+ scop->addScopStmt(BB, Name, SurroundingLoop, Instructions);
Count++;
Instructions.clear();
}
}
- scop->addScopStmt(BB, SurroundingLoop, Instructions, Count);
+ std::string Name = makeStmtName(scop.get(), BB, Count);
+ scop->addScopStmt(BB, Name, SurroundingLoop, Instructions);
}
/// Is @p Inst an ordered instruction?
@@ -874,7 +899,8 @@ void ScopBuilder::buildEqivClassBlockStmts(BasicBlock *BB) {
for (auto &Instructions : reverse(LeaderToInstList)) {
std::vector<Instruction *> &InstList = Instructions.second;
std::reverse(InstList.begin(), InstList.end());
- scop->addScopStmt(BB, L, std::move(InstList), Count);
+ std::string Name = makeStmtName(scop.get(), BB, Count);
+ scop->addScopStmt(BB, Name, L, std::move(InstList));
Count += 1;
}
}
@@ -887,7 +913,8 @@ void ScopBuilder::buildStmts(Region &SR) {
for (Instruction &Inst : *SR.getEntry())
if (shouldModelInst(&Inst, SurroundingLoop))
Instructions.push_back(&Inst);
- scop->addScopStmt(&SR, SurroundingLoop, Instructions);
+ std::string Name = makeStmtName(scop.get(), &SR);
+ scop->addScopStmt(&SR, Name, SurroundingLoop, Instructions);
return;
}
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 1ef900d52a8..9ecf301bb34 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1695,26 +1695,19 @@ bool buildConditionSets(Scop &S, BasicBlock *BB, TerminatorInst *TI, Loop *L,
ConditionSets);
}
-ScopStmt::ScopStmt(Scop &parent, Region &R, Loop *SurroundingLoop,
+ScopStmt::ScopStmt(Scop &parent, Region &R, StringRef Name,
+ Loop *SurroundingLoop,
std::vector<Instruction *> EntryBlockInstructions)
: Parent(parent), InvalidDomain(nullptr), Domain(nullptr), R(&R),
- Build(nullptr), SurroundingLoop(SurroundingLoop),
- Instructions(EntryBlockInstructions) {
- BaseName = getIslCompatibleName(
- "Stmt", R.getNameStr(), parent.getNextStmtIdx(), "", UseInstructionNames);
-}
+ Build(nullptr), BaseName(Name), SurroundingLoop(SurroundingLoop),
+ Instructions(EntryBlockInstructions) {}
-ScopStmt::ScopStmt(Scop &parent, BasicBlock &bb, Loop *SurroundingLoop,
- std::vector<Instruction *> Instructions, int Count)
+ScopStmt::ScopStmt(Scop &parent, BasicBlock &bb, StringRef Name,
+ Loop *SurroundingLoop,
+ std::vector<Instruction *> Instructions)
: Parent(parent), InvalidDomain(nullptr), Domain(nullptr), BB(&bb),
- Build(nullptr), SurroundingLoop(SurroundingLoop),
- Instructions(Instructions) {
- std::string S = "";
- if (Count != 0)
- S += std::to_string(Count);
- BaseName = getIslCompatibleName("Stmt", &bb, parent.getNextStmtIdx(), S,
- UseInstructionNames);
-}
+ Build(nullptr), BaseName(Name), SurroundingLoop(SurroundingLoop),
+ Instructions(Instructions) {}
ScopStmt::ScopStmt(Scop &parent, isl::map SourceRel, isl::map TargetRel,
isl::set NewDomain)
@@ -4644,10 +4637,10 @@ static isl::multi_union_pw_aff mapToDimension(isl::union_set USet, int N) {
return isl::multi_union_pw_aff(isl::union_pw_multi_aff(Result));
}
-void Scop::addScopStmt(BasicBlock *BB, Loop *SurroundingLoop,
- std::vector<Instruction *> Instructions, int Count) {
+void Scop::addScopStmt(BasicBlock *BB, StringRef Name, Loop *SurroundingLoop,
+ std::vector<Instruction *> Instructions) {
assert(BB && "Unexpected nullptr!");
- Stmts.emplace_back(*this, *BB, SurroundingLoop, Instructions, Count);
+ Stmts.emplace_back(*this, *BB, Name, SurroundingLoop, Instructions);
auto *Stmt = &Stmts.back();
StmtMap[BB].push_back(Stmt);
for (Instruction *Inst : Instructions) {
@@ -4657,10 +4650,10 @@ void Scop::addScopStmt(BasicBlock *BB, Loop *SurroundingLoop,
}
}
-void Scop::addScopStmt(Region *R, Loop *SurroundingLoop,
+void Scop::addScopStmt(Region *R, StringRef Name, Loop *SurroundingLoop,
std::vector<Instruction *> Instructions) {
assert(R && "Unexpected nullptr!");
- Stmts.emplace_back(*this, *R, SurroundingLoop, Instructions);
+ Stmts.emplace_back(*this, *R, Name, SurroundingLoop, Instructions);
auto *Stmt = &Stmts.back();
for (Instruction *Inst : Instructions) {
OpenPOWER on IntegriCloud