diff options
| author | Michael Kruse <llvm@meinersbur.de> | 2016-01-27 17:09:17 +0000 |
|---|---|---|
| committer | Michael Kruse <llvm@meinersbur.de> | 2016-01-27 17:09:17 +0000 |
| commit | 70131d341620cb60cb1c516fefd3eb655241b173 (patch) | |
| tree | dd643c8d1c0e38cb1d8b5214da65475d97513957 /polly/lib/Analysis/ScopDetection.cpp | |
| parent | cddde58f1c5d6956f669f690fb65920314f4e727 (diff) | |
| download | bcm5719-llvm-70131d341620cb60cb1c516fefd3eb655241b173.tar.gz bcm5719-llvm-70131d341620cb60cb1c516fefd3eb655241b173.zip | |
Introduce MemAccInst helper class; NFC
MemAccInst wraps the common members of LoadInst and StoreInst. Also use
of this class in:
- ScopInfo::buildMemoryAccess
- BlockGenerator::generateLocationAccessed
- ScopInfo::addArrayAccess
- Scop::buildAliasGroups
- Replace every use of polly::getPointerOperand
Reviewers: jdoerfert, grosser
Differential Revision: http://reviews.llvm.org/D16530
llvm-svn: 258947
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index fb58a0bbcc0..710375676b8 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -758,11 +758,11 @@ bool ScopDetection::hasAffineMemoryAccesses(DetectionContext &Context) const { return true; } -bool ScopDetection::isValidMemoryAccess(Instruction &Inst, +bool ScopDetection::isValidMemoryAccess(MemAccInst Inst, DetectionContext &Context) const { Region &CurRegion = Context.CurRegion; - Value *Ptr = getPointerOperand(Inst); + Value *Ptr = Inst.getPointerOperand(); Loop *L = LI->getLoopFor(Inst.getParent()); const SCEV *AccessFunction = SE->getSCEVAtScope(Ptr, L); const SCEVUnknown *BasePointer; @@ -771,26 +771,26 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst, BasePointer = dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction)); if (!BasePointer) - return invalid<ReportNoBasePtr>(Context, /*Assert=*/true, &Inst); + return invalid<ReportNoBasePtr>(Context, /*Assert=*/true, Inst); BaseValue = BasePointer->getValue(); if (isa<UndefValue>(BaseValue)) - return invalid<ReportUndefBasePtr>(Context, /*Assert=*/true, &Inst); + return invalid<ReportUndefBasePtr>(Context, /*Assert=*/true, Inst); // Check that the base address of the access is invariant in the current // region. if (!isInvariant(*BaseValue, CurRegion)) return invalid<ReportVariantBasePtr>(Context, /*Assert=*/true, BaseValue, - &Inst); + Inst); AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer); - const SCEV *Size = SE->getElementSize(&Inst); + const SCEV *Size = SE->getElementSize(Inst); if (Context.ElementSize.count(BasePointer)) { if (Context.ElementSize[BasePointer] != Size) return invalid<ReportDifferentArrayElementSize>(Context, /*Assert=*/true, - &Inst, BaseValue); + Inst, BaseValue); } else { Context.ElementSize[BasePointer] = Size; } @@ -803,7 +803,7 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst, isVariantInNonAffineLoop = true; if (PollyDelinearize && !isVariantInNonAffineLoop) { - Context.Accesses[BasePointer].push_back({&Inst, AccessFunction}); + Context.Accesses[BasePointer].push_back({Inst, AccessFunction}); if (!isAffine(AccessFunction, Context, BaseValue)) Context.NonAffineAccesses.insert(BasePointer); @@ -811,7 +811,7 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst, if (isVariantInNonAffineLoop || !isAffine(AccessFunction, Context, BaseValue)) return invalid<ReportNonAffineAccess>(Context, /*Assert=*/true, - AccessFunction, &Inst, BaseValue); + AccessFunction, Inst, BaseValue); } // FIXME: Think about allowing IntToPtrInst @@ -853,7 +853,7 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst, if (CanBuildRunTimeCheck) return true; } - return invalid<ReportAlias>(Context, /*Assert=*/true, &Inst, AS); + return invalid<ReportAlias>(Context, /*Assert=*/true, Inst, AS); } return true; @@ -887,19 +887,14 @@ bool ScopDetection::isValidInstruction(Instruction &Inst, } // Check the access function. - if (isa<LoadInst>(Inst) || isa<StoreInst>(Inst)) { - Context.hasStores |= isa<StoreInst>(Inst); - Context.hasLoads |= isa<LoadInst>(Inst); - if (auto *Load = dyn_cast<LoadInst>(&Inst)) - if (!Load->isSimple()) - return invalid<ReportNonSimpleMemoryAccess>(Context, /*Assert=*/true, - &Inst); - if (auto *Store = dyn_cast<StoreInst>(&Inst)) - if (!Store->isSimple()) - return invalid<ReportNonSimpleMemoryAccess>(Context, /*Assert=*/true, - &Inst); - - return isValidMemoryAccess(Inst, Context); + if (auto MemInst = MemAccInst::dyn_cast(Inst)) { + Context.hasStores |= MemInst.isLoad(); + Context.hasLoads |= MemInst.isStore(); + if (!MemInst.isSimple()) + return invalid<ReportNonSimpleMemoryAccess>(Context, /*Assert=*/true, + &Inst); + + return isValidMemoryAccess(MemInst, Context); } // We do not know this instruction, therefore we assume it is invalid. |

