diff options
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 5300dbe49f3..5308b8d0f53 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -190,6 +190,16 @@ void SCEVConstant::print(raw_ostream &OS) const { WriteAsOperand(OS, V, false); } +SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy, + const SCEVHandle &op, const Type *ty) + : SCEV(SCEVTy), Op(op), Ty(ty) {} + +SCEVCastExpr::~SCEVCastExpr() {} + +bool SCEVCastExpr::dominates(BasicBlock *BB, DominatorTree *DT) const { + return Op->dominates(BB, DT); +} + // SCEVTruncates - Only allow the creation of one SCEVTruncateExpr for any // particular input. Don't use a SCEVHandle here, or else the object will // never be deleted! @@ -197,7 +207,7 @@ static ManagedStatic<std::map<std::pair<SCEV*, const Type*>, SCEVTruncateExpr*> > SCEVTruncates; SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty) - : SCEV(scTruncate), Op(op), Ty(ty) { + : SCEVCastExpr(scTruncate, op, ty) { assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) && (Ty->isInteger() || isa<PointerType>(Ty)) && "Cannot truncate non-integer value!"); @@ -207,10 +217,6 @@ SCEVTruncateExpr::~SCEVTruncateExpr() { SCEVTruncates->erase(std::make_pair(Op, Ty)); } -bool SCEVTruncateExpr::dominates(BasicBlock *BB, DominatorTree *DT) const { - return Op->dominates(BB, DT); -} - void SCEVTruncateExpr::print(raw_ostream &OS) const { OS << "(truncate " << *Op << " to " << *Ty << ")"; } @@ -222,7 +228,7 @@ static ManagedStatic<std::map<std::pair<SCEV*, const Type*>, SCEVZeroExtendExpr*> > SCEVZeroExtends; SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty) - : SCEV(scZeroExtend), Op(op), Ty(ty) { + : SCEVCastExpr(scZeroExtend, op, ty) { assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) && (Ty->isInteger() || isa<PointerType>(Ty)) && "Cannot zero extend non-integer value!"); @@ -232,10 +238,6 @@ SCEVZeroExtendExpr::~SCEVZeroExtendExpr() { SCEVZeroExtends->erase(std::make_pair(Op, Ty)); } -bool SCEVZeroExtendExpr::dominates(BasicBlock *BB, DominatorTree *DT) const { - return Op->dominates(BB, DT); -} - void SCEVZeroExtendExpr::print(raw_ostream &OS) const { OS << "(zeroextend " << *Op << " to " << *Ty << ")"; } @@ -247,7 +249,7 @@ static ManagedStatic<std::map<std::pair<SCEV*, const Type*>, SCEVSignExtendExpr*> > SCEVSignExtends; SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty) - : SCEV(scSignExtend), Op(op), Ty(ty) { + : SCEVCastExpr(scSignExtend, op, ty) { assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) && (Ty->isInteger() || isa<PointerType>(Ty)) && "Cannot sign extend non-integer value!"); @@ -257,10 +259,6 @@ SCEVSignExtendExpr::~SCEVSignExtendExpr() { SCEVSignExtends->erase(std::make_pair(Op, Ty)); } -bool SCEVSignExtendExpr::dominates(BasicBlock *BB, DominatorTree *DT) const { - return Op->dominates(BB, DT); -} - void SCEVSignExtendExpr::print(raw_ostream &OS) const { OS << "(signextend " << *Op << " to " << *Ty << ")"; } |