summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-27 21:21:31 +0000
committerDan Gohman <gohman@apple.com>2009-06-27 21:21:31 +0000
commit1c34375f79b7786351c27ae45f0412cfdfa004ed (patch)
treedcadaf64494bd9aa15f59d44f623335024b5b16a /include
parent0a928335fad8a1f6bc2ab5352abb64773a4ef484 (diff)
downloadexternal_llvm-1c34375f79b7786351c27ae45f0412cfdfa004ed.zip
external_llvm-1c34375f79b7786351c27ae45f0412cfdfa004ed.tar.gz
external_llvm-1c34375f79b7786351c27ae45f0412cfdfa004ed.tar.bz2
Convert ScalarEvolution to use BumpPtrAllocator and FoldingSet, instead
of a team of individual allocations and a team of std::maps. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/ScalarEvolution.h36
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpressions.h12
2 files changed, 22 insertions, 26 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h
index d699775..9da5c59 100644
--- a/include/llvm/Analysis/ScalarEvolution.h
+++ b/include/llvm/Analysis/ScalarEvolution.h
@@ -25,6 +25,8 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ValueHandle.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/DenseMap.h"
#include <iosfwd>
@@ -34,20 +36,12 @@ namespace llvm {
class Type;
class ScalarEvolution;
class TargetData;
- class SCEVConstant;
- class SCEVTruncateExpr;
- class SCEVZeroExtendExpr;
- class SCEVCommutativeExpr;
- class SCEVUDivExpr;
- class SCEVSignExtendExpr;
- class SCEVAddRecExpr;
- class SCEVUnknown;
/// SCEV - This class represents an analyzed expression in the program. These
/// are opaque objects that the client is not allowed to do much with
/// directly.
///
- class SCEV {
+ class SCEV : public FoldingSetNode {
const unsigned SCEVType; // The SCEV baseclass this node corresponds to
SCEV(const SCEV &); // DO NOT IMPLEMENT
@@ -58,6 +52,8 @@ namespace llvm {
explicit SCEV(unsigned SCEVTy) :
SCEVType(SCEVTy) {}
+ virtual void Profile(FoldingSetNodeID &ID) const = 0;
+
unsigned getSCEVType() const { return SCEVType; }
/// isLoopInvariant - Return true if the value of this SCEV is unchanging in
@@ -132,6 +128,7 @@ namespace llvm {
SCEVCouldNotCompute();
// None of these methods are valid for this object.
+ virtual void Profile(FoldingSetNodeID &ID) const;
virtual bool isLoopInvariant(const Loop *L) const;
virtual const Type *getType() const;
virtual bool hasComputableLoopEvolution(const Loop *L) const;
@@ -182,7 +179,7 @@ namespace llvm {
/// CouldNotCompute - This SCEV is used to represent unknown trip
/// counts and things.
- const SCEV* CouldNotCompute;
+ SCEVCouldNotCompute CouldNotCompute;
/// Scalars - This is a cache of the scalars we have analyzed so far.
///
@@ -566,23 +563,10 @@ 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;
+ FoldingSet<SCEV> UniqueSCEVs;
+ BumpPtrAllocator SCEVAllocator;
};
}
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 8be1a93..c54c865 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -39,6 +39,8 @@ namespace llvm {
explicit SCEVConstant(ConstantInt *v) :
SCEV(scConstant), V(v) {}
public:
+ virtual void Profile(FoldingSetNodeID &ID) const;
+
ConstantInt *getValue() const { return V; }
virtual bool isLoopInvariant(const Loop *L) const {
@@ -81,6 +83,8 @@ namespace llvm {
SCEVCastExpr(unsigned SCEVTy, const SCEV* op, const Type *ty);
public:
+ virtual void Profile(FoldingSetNodeID &ID) const;
+
const SCEV* getOperand() const { return Op; }
virtual const Type *getType() const { return Ty; }
@@ -200,6 +204,8 @@ namespace llvm {
: SCEV(T), Operands(ops.begin(), ops.end()) {}
public:
+ virtual void Profile(FoldingSetNodeID &ID) const;
+
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
const SCEV* getOperand(unsigned i) const {
assert(i < Operands.size() && "Operand index out of range!");
@@ -330,6 +336,8 @@ namespace llvm {
: SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {}
public:
+ virtual void Profile(FoldingSetNodeID &ID) const;
+
const SCEV* getLHS() const { return LHS; }
const SCEV* getRHS() const { return RHS; }
@@ -389,6 +397,8 @@ namespace llvm {
}
public:
+ virtual void Profile(FoldingSetNodeID &ID) const;
+
const SCEV* getStart() const { return Operands[0]; }
const Loop *getLoop() const { return L; }
@@ -505,6 +515,8 @@ namespace llvm {
SCEV(scUnknown), V(v) {}
public:
+ virtual void Profile(FoldingSetNodeID &ID) const;
+
Value *getValue() const { return V; }
virtual bool isLoopInvariant(const Loop *L) const;