summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/ilist.h
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-07-28 21:51:04 +0000
committerDan Gohman <gohman@apple.com>2008-07-28 21:51:04 +0000
commitfed90b6d097d50881afb45e4d79f430db66dd741 (patch)
tree7ec1a6f6b2a8a37e054b84505502b3346c6680c7 /include/llvm/ADT/ilist.h
parent80e051dfdede65678ac66f1552278338bc1a1b33 (diff)
downloadllvm-fed90b6d097d50881afb45e4d79f430db66dd741.tar.gz
llvm-fed90b6d097d50881afb45e4d79f430db66dd741.tar.bz2
llvm-fed90b6d097d50881afb45e4d79f430db66dd741.tar.xz
Fold the useful features of alist and alist_node into ilist, and
a new ilist_node class, and remove them. Unlike alist_node, ilist_node doesn't attempt to manage storage itself, so it avoids the associated problems, including being opaque in gdb. Adjust the Recycler class so that it doesn't depend on alist_node. Also, change it to use explicit Size and Align parameters, allowing it to work when the largest-sized node doesn't have the greatest alignment requirement. Change MachineInstr's MachineMemOperand list from a pool-backed alist to a std::list for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/ilist.h')
-rw-r--r--include/llvm/ADT/ilist.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h
index 41253e030c..3ffc8010ee 100644
--- a/include/llvm/ADT/ilist.h
+++ b/include/llvm/ADT/ilist.h
@@ -47,10 +47,11 @@ namespace llvm {
template<typename NodeTy, typename Traits> class iplist;
template<typename NodeTy> class ilist_iterator;
-// Template traits for intrusive list. By specializing this template class, you
-// can change what next/prev fields are used to store the links...
+/// ilist_nextprev_traits - A fragment for template traits for intrusive list
+/// that provides default next/prev implementations for common operations.
+///
template<typename NodeTy>
-struct ilist_traits {
+struct ilist_nextprev_traits {
static NodeTy *getPrev(NodeTy *N) { return N->getPrev(); }
static NodeTy *getNext(NodeTy *N) { return N->getNext(); }
static const NodeTy *getPrev(const NodeTy *N) { return N->getPrev(); }
@@ -58,25 +59,43 @@ struct ilist_traits {
static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); }
static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); }
+};
- static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
- static void deleteNode(NodeTy *V) { delete V; }
-
+/// ilist_sentinel_traits - A fragment for template traits for intrusive list
+/// that provides default sentinel implementations for common operations.
+///
+template<typename NodeTy>
+struct ilist_sentinel_traits {
static NodeTy *createSentinel() { return new NodeTy(); }
static void destroySentinel(NodeTy *N) { delete N; }
+};
+
+/// ilist_default_traits - Default template traits for intrusive list.
+/// By inheriting from this, you can easily use default implementations
+/// for all common operations.
+///
+template<typename NodeTy>
+struct ilist_default_traits : ilist_nextprev_traits<NodeTy>,
+ ilist_sentinel_traits<NodeTy> {
+ static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
+ static void deleteNode(NodeTy *V) { delete V; }
void addNodeToList(NodeTy *NTy) {}
void removeNodeFromList(NodeTy *NTy) {}
- void transferNodesFromList(iplist<NodeTy, ilist_traits> &L2,
+ void transferNodesFromList(ilist_default_traits &SrcTraits,
ilist_iterator<NodeTy> first,
ilist_iterator<NodeTy> last) {}
};
+// Template traits for intrusive list. By specializing this template class, you
+// can change what next/prev fields are used to store the links...
+template<typename NodeTy>
+struct ilist_traits : ilist_default_traits<NodeTy> {};
+
// Const traits are the same as nonconst traits...
template<typename Ty>
struct ilist_traits<const Ty> : public ilist_traits<Ty> {};
-
//===----------------------------------------------------------------------===//
// ilist_iterator<Node> - Iterator for intrusive list.
//