diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-22 18:25:46 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-22 18:25:46 +0000 |
commit | c48fbfed38cae976f80adb1c1bbd544df081922b (patch) | |
tree | b19d975014244d6cbb24ba8c79a9f8272a6e09de /include | |
parent | 5b50a2437962c4be4dd06ed672fca9955b9399e3 (diff) | |
download | external_llvm-c48fbfed38cae976f80adb1c1bbd544df081922b.zip external_llvm-c48fbfed38cae976f80adb1c1bbd544df081922b.tar.gz external_llvm-c48fbfed38cae976f80adb1c1bbd544df081922b.tar.bz2 |
Banish global state from ScalarEvolution! SCEV uniquing is now done by tables attached to the ScalarEvolution pass.
This also throws out the SCEV reference counting scheme, as the the SCEVs now have a lifetime controlled by the
ScalarEvolution pass.
Note that SCEVHandle is now a no-op, and will be remove in a future commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73892 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolution.h | 48 | ||||
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpressions.h | 12 |
2 files changed, 29 insertions, 31 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index d73c30f..e25c054 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -35,6 +35,14 @@ namespace llvm { class SCEVHandle; class ScalarEvolution; class TargetData; + class SCEVConstant; + class SCEVTruncateExpr; + class SCEVZeroExtendExpr; + class SCEVCommutativeExpr; + class SCEVUDivExpr; + class SCEVSignExtendExpr; + class SCEVAddRecExpr; + class SCEVUnknown; template<> struct DenseMapInfo<SCEVHandle>; /// SCEV - This class represents an analyzed expression in the program. These @@ -43,15 +51,9 @@ namespace llvm { /// class SCEV { const unsigned SCEVType; // The SCEV baseclass this node corresponds to - mutable unsigned RefCount; friend class SCEVHandle; friend class DenseMapInfo<SCEVHandle>; - void addRef() const { ++RefCount; } - void dropRef() const { - if (--RefCount == 0) - delete this; - } const ScalarEvolution* parent; @@ -61,7 +63,7 @@ namespace llvm { virtual ~SCEV(); public: explicit SCEV(unsigned SCEVTy, const ScalarEvolution* p) : - SCEVType(SCEVTy), RefCount(0), parent(p) {} + SCEVType(SCEVTy), parent(p) {} unsigned getSCEVType() const { return SCEVType; } @@ -159,12 +161,9 @@ namespace llvm { public: SCEVHandle(const SCEV *s) : S(s) { assert(S && "Cannot create a handle to a null SCEV!"); - S->addRef(); - } - SCEVHandle(const SCEVHandle &RHS) : S(RHS.S) { - S->addRef(); } - ~SCEVHandle() { S->dropRef(); } + SCEVHandle(const SCEVHandle &RHS) : S(RHS.S) { } + ~SCEVHandle() { } operator const SCEV*() const { return S; } @@ -176,18 +175,14 @@ namespace llvm { const SCEVHandle &operator=(SCEV *RHS) { if (S != RHS) { - S->dropRef(); S = RHS; - S->addRef(); } return *this; } const SCEVHandle &operator=(const SCEVHandle &RHS) { if (S != RHS.S) { - S->dropRef(); S = RHS.S; - S->addRef(); } return *this; } @@ -209,14 +204,10 @@ namespace llvm { struct DenseMapInfo<SCEVHandle> { static inline SCEVHandle getEmptyKey() { static SCEVCouldNotCompute Empty(0); - if (Empty.RefCount == 0) - Empty.addRef(); return &Empty; } static inline SCEVHandle getTombstoneKey() { static SCEVCouldNotCompute Tombstone(0); - if (Tombstone.RefCount == 0) - Tombstone.addRef(); return &Tombstone; } static unsigned getHashValue(const SCEVHandle &Val) { @@ -639,6 +630,23 @@ namespace llvm { void print(std::ostream *OS, const Module* M = 0) const { if (OS) print(*OS, M); } + + private: + // Uniquing tables. + std::map<ConstantInt*, SCEVConstant*> SCEVConstants; + std::map<std::pair<const SCEV*, const Type*>, + SCEVTruncateExpr*> SCEVTruncates; + std::map<std::pair<const SCEV*, const Type*>, + SCEVZeroExtendExpr*> SCEVZeroExtends; + std::map<std::pair<unsigned, std::vector<const SCEV*> >, + SCEVCommutativeExpr*> SCEVCommExprs; + std::map<std::pair<const SCEV*, const SCEV*>, + SCEVUDivExpr*> SCEVUDivs; + std::map<std::pair<const SCEV*, const Type*>, + SCEVSignExtendExpr*> SCEVSignExtends; + std::map<std::pair<const Loop *, std::vector<const SCEV*> >, + SCEVAddRecExpr*> SCEVAddRecExprs; + std::map<Value*, SCEVUnknown*> SCEVUnknowns; }; } diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 2842356..0cc50f7 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -38,8 +38,6 @@ namespace llvm { ConstantInt *V; explicit SCEVConstant(ConstantInt *v, const ScalarEvolution* p) : SCEV(scConstant, p), V(v) {} - - virtual ~SCEVConstant(); public: ConstantInt *getValue() const { return V; } @@ -116,7 +114,6 @@ namespace llvm { SCEVTruncateExpr(const SCEVHandle &op, const Type *ty, const ScalarEvolution* p); - virtual ~SCEVTruncateExpr(); public: SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, @@ -146,7 +143,6 @@ namespace llvm { SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty, const ScalarEvolution* p); - virtual ~SCEVZeroExtendExpr(); public: SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, @@ -176,7 +172,6 @@ namespace llvm { SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty, const ScalarEvolution* p); - virtual ~SCEVSignExtendExpr(); public: SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, @@ -269,7 +264,6 @@ namespace llvm { const SmallVectorImpl<SCEVHandle> &ops, const ScalarEvolution* p) : SCEVNAryExpr(T, ops, p) {} - ~SCEVCommutativeExpr(); public: SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, @@ -345,7 +339,6 @@ namespace llvm { const ScalarEvolution* p) : SCEV(scUDivExpr, p), LHS(lhs), RHS(rhs) {} - virtual ~SCEVUDivExpr(); public: const SCEVHandle &getLHS() const { return LHS; } const SCEVHandle &getRHS() const { return RHS; } @@ -405,7 +398,6 @@ namespace llvm { assert(Operands[i]->isLoopInvariant(l) && "Operands of AddRec must be loop-invariant!"); } - ~SCEVAddRecExpr(); public: const SCEVHandle &getStart() const { return Operands[0]; } @@ -524,9 +516,7 @@ namespace llvm { Value *V; explicit SCEVUnknown(Value *v, const ScalarEvolution* p) : SCEV(scUnknown, p), V(v) {} - - protected: - ~SCEVUnknown(); + public: Value *getValue() const { return V; } |