summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-16 15:31:45 +0000
committerDan Gohman <gohman@apple.com>2010-08-16 15:31:45 +0000
commitaadb5f5adbdb650c5cdc5ece939aaa30af91b3bc (patch)
treee034ded379c5ed4542d82dd41c58f6cf7df16806 /include
parent3063410e52a760584501b825dc6ffb4c52f4d93b (diff)
downloadllvm-aadb5f5adbdb650c5cdc5ece939aaa30af91b3bc.tar.gz
llvm-aadb5f5adbdb650c5cdc5ece939aaa30af91b3bc.tar.bz2
llvm-aadb5f5adbdb650c5cdc5ece939aaa30af91b3bc.tar.xz
Specialize FoldingSetTrait<SCEV>, providing implementations of node
comparison and hash computation which don't require constructing temporary ID values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/ScalarEvolution.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h
index b084849190..c2cfd385ce 100644
--- a/include/llvm/Analysis/ScalarEvolution.h
+++ b/include/llvm/Analysis/ScalarEvolution.h
@@ -45,12 +45,16 @@ namespace llvm {
class LoopInfo;
class Operator;
class SCEVUnknown;
+ class SCEV;
+ template<> class FoldingSetTrait<SCEV>;
/// 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 : public FoldingSetNode {
+ friend class FoldingSetTrait<SCEV>;
+
/// FastID - A reference to an Interned FoldingSetNodeID for this node.
/// The ScalarEvolution's BumpPtrAllocator holds the data.
FoldingSetNodeIDRef FastID;
@@ -74,9 +78,6 @@ namespace llvm {
unsigned getSCEVType() const { return SCEVType; }
- /// Profile - FoldingSet support.
- void Profile(FoldingSetNodeID& ID) { ID = FastID; }
-
/// isLoopInvariant - Return true if the value of this SCEV is unchanging in
/// the specified loop.
virtual bool isLoopInvariant(const Loop *L) const = 0;
@@ -126,6 +127,21 @@ namespace llvm {
void dump() const;
};
+ // Specialize FoldingSetTrait for SCEV to avoid needing to compute
+ // temporary FoldingSetNodeID values.
+ template<> struct FoldingSetTrait<SCEV> : DefaultFoldingSetTrait<SCEV> {
+ static void Profile(const SCEV &X, FoldingSetNodeID& ID) {
+ ID = X.FastID;
+ }
+ static bool Equals(const SCEV &X, const FoldingSetNodeID &ID,
+ FoldingSetNodeID &TempID) {
+ return ID == X.FastID;
+ }
+ static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID) {
+ return X.FastID.ComputeHash();
+ }
+ };
+
inline raw_ostream &operator<<(raw_ostream &OS, const SCEV &S) {
S.print(OS);
return OS;