class SCEV {
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
- const ScalarEvolution* parent;
-
SCEV(const SCEV &); // DO NOT IMPLEMENT
void operator=(const SCEV &); // DO NOT IMPLEMENT
protected:
virtual ~SCEV();
public:
- explicit SCEV(unsigned SCEVTy, const ScalarEvolution* p) :
- SCEVType(SCEVTy), parent(p) {}
+ explicit SCEV(unsigned SCEVTy) :
+ SCEVType(SCEVTy) {}
unsigned getSCEVType() const { return SCEVType; }
/// None of the standard SCEV operations are valid on this class, it is just a
/// marker.
struct SCEVCouldNotCompute : public SCEV {
- SCEVCouldNotCompute(const ScalarEvolution* p);
- ~SCEVCouldNotCompute();
+ SCEVCouldNotCompute();
// None of these methods are valid for this object.
virtual bool isLoopInvariant(const Loop *L) const;
friend class ScalarEvolution;
ConstantInt *V;
- explicit SCEVConstant(ConstantInt *v, const ScalarEvolution* p) :
- SCEV(scConstant, p), V(v) {}
+ explicit SCEVConstant(ConstantInt *v) :
+ SCEV(scConstant), V(v) {}
public:
ConstantInt *getValue() const { return V; }
const SCEV* Op;
const Type *Ty;
- SCEVCastExpr(unsigned SCEVTy, const SCEV* op, const Type *ty,
- const ScalarEvolution* p);
- virtual ~SCEVCastExpr();
+ SCEVCastExpr(unsigned SCEVTy, const SCEV* op, const Type *ty);
public:
const SCEV* getOperand() const { return Op; }
class SCEVTruncateExpr : public SCEVCastExpr {
friend class ScalarEvolution;
- SCEVTruncateExpr(const SCEV* op, const Type *ty,
- const ScalarEvolution* p);
+ SCEVTruncateExpr(const SCEV* op, const Type *ty);
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
class SCEVZeroExtendExpr : public SCEVCastExpr {
friend class ScalarEvolution;
- SCEVZeroExtendExpr(const SCEV* op, const Type *ty,
- const ScalarEvolution* p);
+ SCEVZeroExtendExpr(const SCEV* op, const Type *ty);
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
class SCEVSignExtendExpr : public SCEVCastExpr {
friend class ScalarEvolution;
- SCEVSignExtendExpr(const SCEV* op, const Type *ty,
- const ScalarEvolution* p);
+ SCEVSignExtendExpr(const SCEV* op, const Type *ty);
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
protected:
SmallVector<const SCEV*, 8> Operands;
- SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<const SCEV*> &ops,
- const ScalarEvolution* p)
- : SCEV(T, p), Operands(ops.begin(), ops.end()) {}
- virtual ~SCEVNAryExpr() {}
+ SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<const SCEV*> &ops)
+ : SCEV(T), Operands(ops.begin(), ops.end()) {}
public:
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
class SCEVCommutativeExpr : public SCEVNAryExpr {
protected:
SCEVCommutativeExpr(enum SCEVTypes T,
- const SmallVectorImpl<const SCEV*> &ops,
- const ScalarEvolution* p)
- : SCEVNAryExpr(T, ops, p) {}
+ const SmallVectorImpl<const SCEV*> &ops)
+ : SCEVNAryExpr(T, ops) {}
public:
const SCEV* replaceSymbolicValuesWithConcrete(const SCEV* Sym,
class SCEVAddExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- explicit SCEVAddExpr(const SmallVectorImpl<const SCEV*> &ops,
- const ScalarEvolution* p)
- : SCEVCommutativeExpr(scAddExpr, ops, p) {
+ explicit SCEVAddExpr(const SmallVectorImpl<const SCEV*> &ops)
+ : SCEVCommutativeExpr(scAddExpr, ops) {
}
public:
class SCEVMulExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- explicit SCEVMulExpr(const SmallVectorImpl<const SCEV*> &ops,
- const ScalarEvolution* p)
- : SCEVCommutativeExpr(scMulExpr, ops, p) {
+ explicit SCEVMulExpr(const SmallVectorImpl<const SCEV*> &ops)
+ : SCEVCommutativeExpr(scMulExpr, ops) {
}
public:
const SCEV* LHS;
const SCEV* RHS;
- SCEVUDivExpr(const SCEV* lhs, const SCEV* rhs,
- const ScalarEvolution* p)
- : SCEV(scUDivExpr, p), LHS(lhs), RHS(rhs) {}
+ SCEVUDivExpr(const SCEV* lhs, const SCEV* rhs)
+ : SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {}
public:
const SCEV* getLHS() const { return LHS; }
const Loop *L;
- SCEVAddRecExpr(const SmallVectorImpl<const SCEV*> &ops, const Loop *l,
- const ScalarEvolution* p)
- : SCEVNAryExpr(scAddRecExpr, ops, p), L(l) {
+ SCEVAddRecExpr(const SmallVectorImpl<const SCEV*> &ops, const Loop *l)
+ : SCEVNAryExpr(scAddRecExpr, ops), L(l) {
for (size_t i = 0, e = Operands.size(); i != e; ++i)
assert(Operands[i]->isLoopInvariant(l) &&
"Operands of AddRec must be loop-invariant!");
class SCEVSMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- explicit SCEVSMaxExpr(const SmallVectorImpl<const SCEV*> &ops,
- const ScalarEvolution* p)
- : SCEVCommutativeExpr(scSMaxExpr, ops, p) {
+ explicit SCEVSMaxExpr(const SmallVectorImpl<const SCEV*> &ops)
+ : SCEVCommutativeExpr(scSMaxExpr, ops) {
}
public:
class SCEVUMaxExpr : public SCEVCommutativeExpr {
friend class ScalarEvolution;
- explicit SCEVUMaxExpr(const SmallVectorImpl<const SCEV*> &ops,
- const ScalarEvolution* p)
- : SCEVCommutativeExpr(scUMaxExpr, ops, p) {
+ explicit SCEVUMaxExpr(const SmallVectorImpl<const SCEV*> &ops)
+ : SCEVCommutativeExpr(scUMaxExpr, ops) {
}
public:
friend class ScalarEvolution;
Value *V;
- explicit SCEVUnknown(Value *v, const ScalarEvolution* p) :
- SCEV(scUnknown, p), V(v) {}
+ explicit SCEVUnknown(Value *v) :
+ SCEV(scUnknown), V(v) {}
public:
Value *getValue() const { return V; }
#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstIterator.h"
-#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
return false;
}
-SCEVCouldNotCompute::SCEVCouldNotCompute(const ScalarEvolution* p) :
- SCEV(scCouldNotCompute, p) {}
-SCEVCouldNotCompute::~SCEVCouldNotCompute() {}
+SCEVCouldNotCompute::SCEVCouldNotCompute() :
+ SCEV(scCouldNotCompute) {}
bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const {
assert(0 && "Attempt to use a SCEVCouldNotCompute object!");
const SCEV* ScalarEvolution::getConstant(ConstantInt *V) {
SCEVConstant *&R = SCEVConstants[V];
- if (R == 0) R = new SCEVConstant(V, this);
+ if (R == 0) R = new SCEVConstant(V);
return R;
}
}
SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy,
- const SCEV* op, const Type *ty,
- const ScalarEvolution* p)
- : SCEV(SCEVTy, p), Op(op), Ty(ty) {}
-
-SCEVCastExpr::~SCEVCastExpr() {}
+ const SCEV* op, const Type *ty)
+ : SCEV(SCEVTy), Op(op), Ty(ty) {}
bool SCEVCastExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
return Op->dominates(BB, DT);
// particular input. Don't use a const SCEV* here, or else the object will
// never be deleted!
-SCEVTruncateExpr::SCEVTruncateExpr(const SCEV* op, const Type *ty,
- const ScalarEvolution* p)
- : SCEVCastExpr(scTruncate, op, ty, p) {
+SCEVTruncateExpr::SCEVTruncateExpr(const SCEV* op, const Type *ty)
+ : SCEVCastExpr(scTruncate, op, ty) {
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot truncate non-integer value!");
// particular input. Don't use a const SCEV* here, or else the object will never
// be deleted!
-SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV* op, const Type *ty,
- const ScalarEvolution* p)
- : SCEVCastExpr(scZeroExtend, op, ty, p) {
+SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEV* op, const Type *ty)
+ : SCEVCastExpr(scZeroExtend, op, ty) {
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot zero extend non-integer value!");
// particular input. Don't use a const SCEV* here, or else the object will never
// be deleted!
-SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV* op, const Type *ty,
- const ScalarEvolution* p)
- : SCEVCastExpr(scSignExtend, op, ty, p) {
+SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEV* op, const Type *ty)
+ : SCEVCastExpr(scSignExtend, op, ty) {
assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot sign extend non-integer value!");
}
SCEVTruncateExpr *&Result = SCEVTruncates[std::make_pair(Op, Ty)];
- if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty, this);
+ if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty);
return Result;
}
}
SCEVZeroExtendExpr *&Result = SCEVZeroExtends[std::make_pair(Op, Ty)];
- if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty, this);
+ if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty);
return Result;
}
}
SCEVSignExtendExpr *&Result = SCEVSignExtends[std::make_pair(Op, Ty)];
- if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty, this);
+ if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty);
return Result;
}
std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scAddExpr,
SCEVOps)];
- if (Result == 0) Result = new SCEVAddExpr(Ops, this);
+ if (Result == 0) Result = new SCEVAddExpr(Ops);
return Result;
}
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scMulExpr,
SCEVOps)];
if (Result == 0)
- Result = new SCEVMulExpr(Ops, this);
+ Result = new SCEVMulExpr(Ops);
return Result;
}
}
SCEVUDivExpr *&Result = SCEVUDivs[std::make_pair(LHS, RHS)];
- if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS, this);
+ if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS);
return Result;
}
std::vector<const SCEV*> SCEVOps(Operands.begin(), Operands.end());
SCEVAddRecExpr *&Result = SCEVAddRecExprs[std::make_pair(L, SCEVOps)];
- if (Result == 0) Result = new SCEVAddRecExpr(Operands, L, this);
+ if (Result == 0) Result = new SCEVAddRecExpr(Operands, L);
return Result;
}
std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scSMaxExpr,
SCEVOps)];
- if (Result == 0) Result = new SCEVSMaxExpr(Ops, this);
+ if (Result == 0) Result = new SCEVSMaxExpr(Ops);
return Result;
}
std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scUMaxExpr,
SCEVOps)];
- if (Result == 0) Result = new SCEVUMaxExpr(Ops, this);
+ if (Result == 0) Result = new SCEVUMaxExpr(Ops);
return Result;
}
if (isa<ConstantPointerNull>(V))
return getIntegerSCEV(0, V->getType());
SCEVUnknown *&Result = SCEVUnknowns[V];
- if (Result == 0) Result = new SCEVUnknown(V, this);
+ if (Result == 0) Result = new SCEVUnknown(V);
return Result;
}
//===----------------------------------------------------------------------===//
ScalarEvolution::ScalarEvolution()
- : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute(0)) {
+ : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute()) {
}
bool ScalarEvolution::runOnFunction(Function &F) {