[llvm-commits] [llvm] r111131 - /llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
Dan Gohman
gohman at apple.com
Mon Aug 16 08:31:45 PDT 2010
Author: djg
Date: Mon Aug 16 10:31:45 2010
New Revision: 111131
URL: http://llvm.org/viewvc/llvm-project?rev=111131&view=rev
Log:
Specialize FoldingSetTrait<SCEV>, providing implementations of node
comparison and hash computation which don't require constructing
temporary ID values.
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=111131&r1=111130&r2=111131&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon Aug 16 10:31:45 2010
@@ -45,12 +45,16 @@
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 @@
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 @@
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;
More information about the llvm-commits
mailing list