[ScopBuilder/ScopInfo] Move ScopStmt::buildAccessRelations to ScopBuilder. NFC.

This method is only called in the SCoP building phase.
Therefore it fits better into ScopBuilder to separate
SCoP-construction from SCoP modeling.

This mostly mechanical change makes ScopBuilder directly access some of
ScopStmt/MemoryAccess private fields. We add ScopBuilder as a friend
class and will add proper accessor functions sometime later.

llvm-svn: 312115
This commit is contained in:
Michael Kruse 2017-08-30 13:04:46 +00:00
parent f6eb3a2ed2
commit a29f8c03d4
4 changed files with 26 additions and 26 deletions

View File

@ -335,6 +335,9 @@ class ScopBuilder {
/// @see MemoryKind
void addPHIReadAccess(ScopStmt *PHIStmt, PHINode *PHI);
/// Build the access relation of all memory accesses of @p Stmt.
void buildAccessRelations(ScopStmt &Stmt);
public:
explicit ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA,
const DataLayout &DL, DominatorTree &DT, LoopInfo &LI,

View File

@ -477,6 +477,7 @@ private:
class MemoryAccess {
friend class Scop;
friend class ScopStmt;
friend class ScopBuilder;
public:
/// The access type of a memory access
@ -1315,9 +1316,6 @@ private:
/// Fill NestLoops with loops surrounding this statement.
void collectSurroundingLoops();
/// Build the access relation of all memory accesses.
void buildAccessRelations();
/// Detect and mark reductions in the ScopStmt
void checkForReductions();

View File

@ -911,6 +911,27 @@ void ScopBuilder::addPHIReadAccess(ScopStmt *PHIStmt, PHINode *PHI) {
MemoryKind::PHI);
}
void ScopBuilder::buildAccessRelations(ScopStmt &Stmt) {
for (MemoryAccess *Access : Stmt.MemAccs) {
Type *ElementType = Access->getElementType();
MemoryKind Ty;
if (Access->isPHIKind())
Ty = MemoryKind::PHI;
else if (Access->isExitPHIKind())
Ty = MemoryKind::ExitPHI;
else if (Access->isValueKind())
Ty = MemoryKind::Value;
else
Ty = MemoryKind::Array;
auto *SAI = scop->getOrCreateScopArrayInfo(Access->getOriginalBaseAddr(),
ElementType, Access->Sizes, Ty);
Access->buildAccessRelation(SAI);
scop->addAccessData(Access);
}
}
#ifndef NDEBUG
static void verifyUse(Scop *S, Use &Op, LoopInfo &LI) {
auto PhysUse = VirtualUse::create(S, Op, &LI, false);
@ -1050,7 +1071,7 @@ void ScopBuilder::buildScop(Region &R, AssumptionCache &AC,
for (ScopStmt &Stmt : *scop) {
Stmt.buildDomain();
Stmt.collectSurroundingLoops();
Stmt.buildAccessRelations();
buildAccessRelations(Stmt);
if (DetectReductions)
Stmt.checkForReductions();

View File

@ -1308,28 +1308,6 @@ void ScopStmt::restrictDomain(isl::set NewDomain) {
Domain = NewDomain;
}
void ScopStmt::buildAccessRelations() {
Scop &S = *getParent();
for (MemoryAccess *Access : MemAccs) {
Type *ElementType = Access->getElementType();
MemoryKind Ty;
if (Access->isPHIKind())
Ty = MemoryKind::PHI;
else if (Access->isExitPHIKind())
Ty = MemoryKind::ExitPHI;
else if (Access->isValueKind())
Ty = MemoryKind::Value;
else
Ty = MemoryKind::Array;
auto *SAI = S.getOrCreateScopArrayInfo(Access->getOriginalBaseAddr(),
ElementType, Access->Sizes, Ty);
Access->buildAccessRelation(SAI);
S.addAccessData(Access);
}
}
void ScopStmt::addAccess(MemoryAccess *Access, bool Prepend) {
Instruction *AccessInst = Access->getAccessInstruction();