summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-22 18:25:46 +0000
committerOwen Anderson <resistor@mac.com>2009-06-22 18:25:46 +0000
commit86837616f79b0faef24cd81a86ccde14f27643cb (patch)
treefb8163bcab37c8bb772778f85f229d2d001a9cef /llvm/include
parentb8b636d145e62310f5f354d57a291576af9aad60 (diff)
downloadbcm5719-llvm-86837616f79b0faef24cd81a86ccde14f27643cb.tar.gz
bcm5719-llvm-86837616f79b0faef24cd81a86ccde14f27643cb.zip
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. llvm-svn: 73892
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Analysis/ScalarEvolution.h48
-rw-r--r--llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h12
2 files changed, 29 insertions, 31 deletions
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index d73c30fb07c..e25c054698c 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/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/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 28423569d2e..0cc50f756f9 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/llvm/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; }
OpenPOWER on IntegriCloud