#ifndef LLVM_ADT_FOLDINGSET_H
#define LLVM_ADT_FOLDINGSET_H
+#include "llvm/Support/DataTypes.h"
#include "llvm/ADT/SmallVector.h"
+#include <string>
namespace llvm {
///
unsigned NumBuckets;
- /// NumNodes - Number of nodes in the folding set. Growth occurs when NumNodes
+ /// NumNodes - Number of nodes in the folding set. Growth occurs when NumNodes
/// is greater than twice the number of buckets.
unsigned NumNodes;
public:
- FoldingSetImpl();
- ~FoldingSetImpl();
+ FoldingSetImpl(unsigned Log2InitSize = 6);
+ virtual ~FoldingSetImpl();
// Forward declaration.
class Node;
typedef FoldingSetImpl::Node FoldingSetNode;
typedef FoldingSetImpl::NodeID FoldingSetNodeID;
-//===--------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
/// FoldingSet - This template class is used to instantiate a specialized
/// implementation of the folding set to the node class T. T must be a
/// subclass of FoldingSetNode and implement a Profile function.
///
template<class T> class FoldingSet : public FoldingSetImpl {
private:
- /// GetNodeProfile - Each instantiatation of the FoldingSet
+ /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a
+ /// way to convert nodes into a unique specifier.
virtual void GetNodeProfile(NodeID &ID, Node *N) const {
T *TN = static_cast<T *>(N);
TN->Profile(ID);
}
public:
+ FoldingSet(unsigned Log2InitSize = 6)
+ : FoldingSetImpl(Log2InitSize)
+ {}
+
/// GetOrInsertNode - If there is an existing simple Node exactly
/// equal to the specified node, return it. Otherwise, insert 'N' and
/// return it instead.
/// return it. If not, return the insertion token that will make insertion
/// faster.
T *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos) {
- return static_cast<T *>(FoldingSetImpl::FindNodeOrInsertPos(ID,
- InsertPos));
+ return static_cast<T *>(FoldingSetImpl::FindNodeOrInsertPos(ID, InsertPos));
}
};
-}; // End of namespace llvm.
+} // End of namespace llvm.
#endif