13#ifndef POLLY_SCEV_AFFINATOR_H
14#define POLLY_SCEV_AFFINATOR_H
17#include "llvm/Analysis/ScalarEvolutionExpressions.h"
27typedef std::pair<isl::pw_aff, isl::set>
PWACtx;
30class SCEVAffinator final :
public llvm::SCEVVisitor<SCEVAffinator, PWACtx> {
54 llvm::LoopInfo *
getLI()
const {
return &
LI; }
58 using CacheKey = std::pair<const llvm::SCEV *, llvm::BasicBlock *>;
66 llvm::ScalarEvolution &
SE;
72 const llvm::DataLayout &
TD;
Translate a SCEV to an isl::pw_aff and the domain on which it is invalid.
PWACtx visitMulExpr(const llvm::SCEVMulExpr *E)
PWACtx visitUMinExpr(const llvm::SCEVUMinExpr *E)
void interpretAsUnsigned(PWACtx &PWAC, unsigned Width)
Interpret the PWA in PWAC as an unsigned value.
bool computeModuloForExpr(const llvm::SCEV *Expr)
Whether to track the value of this expression precisely, rather than assuming it won't wrap.
PWACtx visitUMaxExpr(const llvm::SCEVUMaxExpr *E)
PWACtx visitUDivExpr(const llvm::SCEVUDivExpr *E)
PWACtx visit(const llvm::SCEV *E)
bool hasNSWAddRecForLoop(llvm::Loop *L) const
Check an <nsw> AddRec for the loop L is cached.
PWACtx complexityBailout()
void takeNonNegativeAssumption(PWACtx &PWAC, RecordedAssumptionsTy *RecordedAssumptions=nullptr)
Take the assumption that PWAC is non-negative.
llvm::DenseMap< CacheKey, PWACtx > CachedExpressions
Map to remembered cached expressions.
RecordedAssumptionsTy * RecordedAssumptions
llvm::LoopInfo * getLI() const
Return the LoopInfo used by thi object.
PWACtx visitTruncateExpr(const llvm::SCEVTruncateExpr *E)
PWACtx visitSMinExpr(const llvm::SCEVSMinExpr *E)
PWACtx visitSDivInstruction(llvm::Instruction *SDiv)
PWACtx visitConstant(const llvm::SCEVConstant *E)
PWACtx visitPtrToIntExpr(const llvm::SCEVPtrToIntExpr *E)
const llvm::DataLayout & TD
Target data for element size computing.
std::pair< const llvm::SCEV *, llvm::BasicBlock * > CacheKey
Key to identify cached expressions.
PWACtx visitAddExpr(const llvm::SCEVAddExpr *E)
PWACtx visitVScale(const llvm::SCEVVScale *E)
PWACtx visitSequentialUMinExpr(const llvm::SCEVSequentialUMinExpr *E)
PWACtx getPwAff(const llvm::SCEV *E, llvm::BasicBlock *BB=nullptr, RecordedAssumptionsTy *RecordedAssumptions=nullptr)
Translate a SCEV to an isl::pw_aff.
isl::pw_aff addModuloSemantic(isl::pw_aff PWA, llvm::Type *ExprType) const
Compute the non-wrapping version of PWA for type ExprType.
llvm::ScalarEvolution & SE
PWACtx visitSRemInstruction(llvm::Instruction *SRem)
PWACtx visitAddRecExpr(const llvm::SCEVAddRecExpr *E)
PWACtx checkForWrapping(const llvm::SCEV *Expr, PWACtx PWAC) const
If Expr might cause an integer wrap record an assumption.
PWACtx visitUnknown(const llvm::SCEVUnknown *E)
PWACtx getPWACtxFromPWA(isl::pw_aff PWA)
Return a PWACtx for PWA that is always valid.
llvm::Loop * getScope()
Return the loop for the current block if any.
PWACtx visitSMaxExpr(const llvm::SCEVSMaxExpr *E)
PWACtx visitSignExtendExpr(const llvm::SCEVSignExtendExpr *E)
PWACtx visitZeroExtendExpr(const llvm::SCEVZeroExtendExpr *E)
std::pair< isl::pw_aff, isl::set > PWACtx
The result type of the SCEVAffinator.
llvm::SmallVector< Assumption, 8 > RecordedAssumptionsTy