[llvm-commits] [llvm] r73728 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h include/llvm/Analysis/ScalarEvolutionExpressions.h lib/Analysis/ScalarEvolution.cpp
Nick Lewycky
nicholas at mxc.ca
Thu Jun 18 19:11:28 PDT 2009
Owen Anderson wrote:
> Author: resistor
> Date: Thu Jun 18 17:25:12 2009
> New Revision: 73728
>
> URL: http://llvm.org/viewvc/llvm-project?rev=73728&view=rev
> Log:
> Add a parent pointer to SCEV, in preparation for getting rid of the global uniquing tables. No functionality change.
Wait, what? Owen, would you mind explaining what your plans are here?
Are you planning to no longer unique SCEVs?
Nick
> Modified:
> llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
> llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
> llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>
> Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=73728&r1=73727&r2=73728&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
> +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Thu Jun 18 17:25:12 2009
> @@ -53,12 +53,15 @@
> delete this;
> }
>
> + const ScalarEvolution* parent;
> +
> SCEV(const SCEV &); // DO NOT IMPLEMENT
> void operator=(const SCEV &); // DO NOT IMPLEMENT
> protected:
> virtual ~SCEV();
> public:
> - explicit SCEV(unsigned SCEVTy) : SCEVType(SCEVTy), RefCount(0) {}
> + explicit SCEV(unsigned SCEVTy, const ScalarEvolution* p) :
> + SCEVType(SCEVTy), RefCount(0), parent(p) {}
>
> unsigned getSCEVType() const { return SCEVType; }
>
> @@ -126,7 +129,7 @@
> /// None of the standard SCEV operations are valid on this class, it is just a
> /// marker.
> struct SCEVCouldNotCompute : public SCEV {
> - SCEVCouldNotCompute();
> + SCEVCouldNotCompute(const ScalarEvolution* p);
> ~SCEVCouldNotCompute();
>
> // None of these methods are valid for this object.
> @@ -205,13 +208,13 @@
> template<>
> struct DenseMapInfo<SCEVHandle> {
> static inline SCEVHandle getEmptyKey() {
> - static SCEVCouldNotCompute Empty;
> + static SCEVCouldNotCompute Empty(0);
> if (Empty.RefCount == 0)
> Empty.addRef();
> return &Empty;
> }
> static inline SCEVHandle getTombstoneKey() {
> - static SCEVCouldNotCompute Tombstone;
> + static SCEVCouldNotCompute Tombstone(0);
> if (Tombstone.RefCount == 0)
> Tombstone.addRef();
> return &Tombstone;
>
> Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=73728&r1=73727&r2=73728&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original)
> +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Thu Jun 18 17:25:12 2009
> @@ -36,7 +36,8 @@
> friend class ScalarEvolution;
>
> ConstantInt *V;
> - explicit SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {}
> + explicit SCEVConstant(ConstantInt *v, const ScalarEvolution* p) :
> + SCEV(scConstant, p), V(v) {}
>
> virtual ~SCEVConstant();
> public:
> @@ -79,7 +80,8 @@
> SCEVHandle Op;
> const Type *Ty;
>
> - SCEVCastExpr(unsigned SCEVTy, const SCEVHandle &op, const Type *ty);
> + SCEVCastExpr(unsigned SCEVTy, const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p);
> virtual ~SCEVCastExpr();
>
> public:
> @@ -112,7 +114,8 @@
> class SCEVTruncateExpr : public SCEVCastExpr {
> friend class ScalarEvolution;
>
> - SCEVTruncateExpr(const SCEVHandle &op, const Type *ty);
> + SCEVTruncateExpr(const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p);
> virtual ~SCEVTruncateExpr();
>
> public:
> @@ -141,7 +144,8 @@
> class SCEVZeroExtendExpr : public SCEVCastExpr {
> friend class ScalarEvolution;
>
> - SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty);
> + SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p);
> virtual ~SCEVZeroExtendExpr();
>
> public:
> @@ -170,7 +174,8 @@
> class SCEVSignExtendExpr : public SCEVCastExpr {
> friend class ScalarEvolution;
>
> - SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty);
> + SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p);
> virtual ~SCEVSignExtendExpr();
>
> public:
> @@ -201,8 +206,9 @@
> protected:
> SmallVector<SCEVHandle, 8> Operands;
>
> - SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops)
> - : SCEV(T), Operands(ops.begin(), ops.end()) {}
> + SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops,
> + const ScalarEvolution* p)
> + : SCEV(T, p), Operands(ops.begin(), ops.end()) {}
> virtual ~SCEVNAryExpr() {}
>
> public:
> @@ -259,8 +265,10 @@
> ///
> class SCEVCommutativeExpr : public SCEVNAryExpr {
> protected:
> - SCEVCommutativeExpr(enum SCEVTypes T, const SmallVectorImpl<SCEVHandle> &ops)
> - : SCEVNAryExpr(T, ops) {}
> + SCEVCommutativeExpr(enum SCEVTypes T,
> + const SmallVectorImpl<SCEVHandle> &ops,
> + const ScalarEvolution* p)
> + : SCEVNAryExpr(T, ops, p) {}
> ~SCEVCommutativeExpr();
>
> public:
> @@ -289,8 +297,9 @@
> class SCEVAddExpr : public SCEVCommutativeExpr {
> friend class ScalarEvolution;
>
> - explicit SCEVAddExpr(const SmallVectorImpl<SCEVHandle> &ops)
> - : SCEVCommutativeExpr(scAddExpr, ops) {
> + explicit SCEVAddExpr(const SmallVectorImpl<SCEVHandle> &ops,
> + const ScalarEvolution* p)
> + : SCEVCommutativeExpr(scAddExpr, ops, p) {
> }
>
> public:
> @@ -309,8 +318,9 @@
> class SCEVMulExpr : public SCEVCommutativeExpr {
> friend class ScalarEvolution;
>
> - explicit SCEVMulExpr(const SmallVectorImpl<SCEVHandle> &ops)
> - : SCEVCommutativeExpr(scMulExpr, ops) {
> + explicit SCEVMulExpr(const SmallVectorImpl<SCEVHandle> &ops,
> + const ScalarEvolution* p)
> + : SCEVCommutativeExpr(scMulExpr, ops, p) {
> }
>
> public:
> @@ -331,8 +341,9 @@
> friend class ScalarEvolution;
>
> SCEVHandle LHS, RHS;
> - SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs)
> - : SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {}
> + SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs,
> + const ScalarEvolution* p)
> + : SCEV(scUDivExpr, p), LHS(lhs), RHS(rhs) {}
>
> virtual ~SCEVUDivExpr();
> public:
> @@ -387,8 +398,9 @@
>
> const Loop *L;
>
> - SCEVAddRecExpr(const SmallVectorImpl<SCEVHandle> &ops, const Loop *l)
> - : SCEVNAryExpr(scAddRecExpr, ops), L(l) {
> + SCEVAddRecExpr(const SmallVectorImpl<SCEVHandle> &ops, const Loop *l,
> + const ScalarEvolution* p)
> + : SCEVNAryExpr(scAddRecExpr, ops, p), 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!");
> @@ -463,8 +475,9 @@
> class SCEVSMaxExpr : public SCEVCommutativeExpr {
> friend class ScalarEvolution;
>
> - explicit SCEVSMaxExpr(const SmallVectorImpl<SCEVHandle> &ops)
> - : SCEVCommutativeExpr(scSMaxExpr, ops) {
> + explicit SCEVSMaxExpr(const SmallVectorImpl<SCEVHandle> &ops,
> + const ScalarEvolution* p)
> + : SCEVCommutativeExpr(scSMaxExpr, ops, p) {
> }
>
> public:
> @@ -484,8 +497,9 @@
> class SCEVUMaxExpr : public SCEVCommutativeExpr {
> friend class ScalarEvolution;
>
> - explicit SCEVUMaxExpr(const SmallVectorImpl<SCEVHandle> &ops)
> - : SCEVCommutativeExpr(scUMaxExpr, ops) {
> + explicit SCEVUMaxExpr(const SmallVectorImpl<SCEVHandle> &ops,
> + const ScalarEvolution* p)
> + : SCEVCommutativeExpr(scUMaxExpr, ops, p) {
> }
>
> public:
> @@ -508,7 +522,8 @@
> friend class ScalarEvolution;
>
> Value *V;
> - explicit SCEVUnknown(Value *v) : SCEV(scUnknown), V(v) {}
> + explicit SCEVUnknown(Value *v, const ScalarEvolution* p) :
> + SCEV(scUnknown, p), V(v) {}
>
> protected:
> ~SCEVUnknown();
>
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73728&r1=73727&r2=73728&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Jun 18 17:25:12 2009
> @@ -133,7 +133,8 @@
> return false;
> }
>
> -SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {}
> +SCEVCouldNotCompute::SCEVCouldNotCompute(const ScalarEvolution* p) :
> + SCEV(scCouldNotCompute, p) {}
> SCEVCouldNotCompute::~SCEVCouldNotCompute() {}
>
> bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const {
> @@ -179,7 +180,7 @@
>
> SCEVHandle ScalarEvolution::getConstant(ConstantInt *V) {
> SCEVConstant *&R = (*SCEVConstants)[V];
> - if (R == 0) R = new SCEVConstant(V);
> + if (R == 0) R = new SCEVConstant(V, this);
> return R;
> }
>
> @@ -199,8 +200,9 @@
> }
>
> SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy,
> - const SCEVHandle &op, const Type *ty)
> - : SCEV(SCEVTy), Op(op), Ty(ty) {}
> + const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p)
> + : SCEV(SCEVTy, p), Op(op), Ty(ty) {}
>
> SCEVCastExpr::~SCEVCastExpr() {}
>
> @@ -214,8 +216,9 @@
> static ManagedStatic<std::map<std::pair<const SCEV*, const Type*>,
> SCEVTruncateExpr*> > SCEVTruncates;
>
> -SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty)
> - : SCEVCastExpr(scTruncate, op, ty) {
> +SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p)
> + : SCEVCastExpr(scTruncate, op, ty, p) {
> assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
> (Ty->isInteger() || isa<PointerType>(Ty)) &&
> "Cannot truncate non-integer value!");
> @@ -235,8 +238,9 @@
> static ManagedStatic<std::map<std::pair<const SCEV*, const Type*>,
> SCEVZeroExtendExpr*> > SCEVZeroExtends;
>
> -SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty)
> - : SCEVCastExpr(scZeroExtend, op, ty) {
> +SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p)
> + : SCEVCastExpr(scZeroExtend, op, ty, p) {
> assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
> (Ty->isInteger() || isa<PointerType>(Ty)) &&
> "Cannot zero extend non-integer value!");
> @@ -256,8 +260,9 @@
> static ManagedStatic<std::map<std::pair<const SCEV*, const Type*>,
> SCEVSignExtendExpr*> > SCEVSignExtends;
>
> -SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty)
> - : SCEVCastExpr(scSignExtend, op, ty) {
> +SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty,
> + const ScalarEvolution* p)
> + : SCEVCastExpr(scSignExtend, op, ty, p) {
> assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
> (Ty->isInteger() || isa<PointerType>(Ty)) &&
> "Cannot sign extend non-integer value!");
> @@ -787,7 +792,7 @@
> }
>
> SCEVTruncateExpr *&Result = (*SCEVTruncates)[std::make_pair(Op, Ty)];
> - if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty);
> + if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty, this);
> return Result;
> }
>
> @@ -875,7 +880,7 @@
> }
>
> SCEVZeroExtendExpr *&Result = (*SCEVZeroExtends)[std::make_pair(Op, Ty)];
> - if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty);
> + if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty, this);
> return Result;
> }
>
> @@ -947,7 +952,7 @@
> }
>
> SCEVSignExtendExpr *&Result = (*SCEVSignExtends)[std::make_pair(Op, Ty)];
> - if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty);
> + if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty, this);
> return Result;
> }
>
> @@ -1409,7 +1414,7 @@
> std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
> SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scAddExpr,
> SCEVOps)];
> - if (Result == 0) Result = new SCEVAddExpr(Ops);
> + if (Result == 0) Result = new SCEVAddExpr(Ops, this);
> return Result;
> }
>
> @@ -1575,7 +1580,7 @@
> SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scMulExpr,
> SCEVOps)];
> if (Result == 0)
> - Result = new SCEVMulExpr(Ops);
> + Result = new SCEVMulExpr(Ops, this);
> return Result;
> }
>
> @@ -1666,7 +1671,7 @@
> }
>
> SCEVUDivExpr *&Result = (*SCEVUDivs)[std::make_pair(LHS, RHS)];
> - if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS);
> + if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS, this);
> return Result;
> }
>
> @@ -1720,7 +1725,7 @@
>
> 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);
> + if (Result == 0) Result = new SCEVAddRecExpr(Operands, L, this);
> return Result;
> }
>
> @@ -1807,7 +1812,7 @@
> std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
> SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scSMaxExpr,
> SCEVOps)];
> - if (Result == 0) Result = new SCEVSMaxExpr(Ops);
> + if (Result == 0) Result = new SCEVSMaxExpr(Ops, this);
> return Result;
> }
>
> @@ -1894,7 +1899,7 @@
> std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
> SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scUMaxExpr,
> SCEVOps)];
> - if (Result == 0) Result = new SCEVUMaxExpr(Ops);
> + if (Result == 0) Result = new SCEVUMaxExpr(Ops, this);
> return Result;
> }
>
> @@ -1904,7 +1909,7 @@
> if (isa<ConstantPointerNull>(V))
> return getIntegerSCEV(0, V->getType());
> SCEVUnknown *&Result = (*SCEVUnknowns)[V];
> - if (Result == 0) Result = new SCEVUnknown(V);
> + if (Result == 0) Result = new SCEVUnknown(V, this);
> return Result;
> }
>
> @@ -3978,7 +3983,7 @@
> //===----------------------------------------------------------------------===//
>
> ScalarEvolution::ScalarEvolution()
> - : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute()) {
> + : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute(0)) {
> }
>
> bool ScalarEvolution::runOnFunction(Function &F) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list