diff options
author | Dan Gohman <gohman@apple.com> | 2008-07-28 21:51:04 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-07-28 21:51:04 +0000 |
commit | fed90b6d097d50881afb45e4d79f430db66dd741 (patch) | |
tree | 7ec1a6f6b2a8a37e054b84505502b3346c6680c7 | |
parent | 80e051dfdede65678ac66f1552278338bc1a1b33 (diff) |
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
33 files changed, 340 insertions, 815 deletions
diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h index adeb541d3d..efd0accaad 100644 --- a/include/llvm/ADT/SparseBitVector.h +++ b/include/llvm/ADT/SparseBitVector.h @@ -39,7 +39,8 @@ namespace llvm { template <unsigned ElementSize = 128> -struct SparseBitVectorElement { +struct SparseBitVectorElement + : ilist_node<SparseBitVectorElement<ElementSize> > { public: typedef unsigned long BitWord; enum { @@ -48,56 +49,23 @@ public: BITS_PER_ELEMENT = ElementSize }; - SparseBitVectorElement<ElementSize> *getNext() const { - return Next; - } - SparseBitVectorElement<ElementSize> *getPrev() const { - return Prev; - } - - void setNext(SparseBitVectorElement<ElementSize> *RHS) { - Next = RHS; - } - void setPrev(SparseBitVectorElement<ElementSize> *RHS) { - Prev = RHS; - } - private: - SparseBitVectorElement<ElementSize> *Next; - SparseBitVectorElement<ElementSize> *Prev; // Index of Element in terms of where first bit starts. unsigned ElementIndex; BitWord Bits[BITWORDS_PER_ELEMENT]; // Needed for sentinels + friend class ilist_sentinel_traits<SparseBitVectorElement>; SparseBitVectorElement() { ElementIndex = ~0U; memset(&Bits[0], 0, sizeof (BitWord) * BITWORDS_PER_ELEMENT); } - friend struct ilist_traits<SparseBitVectorElement<ElementSize> >; public: explicit SparseBitVectorElement(unsigned Idx) { ElementIndex = Idx; memset(&Bits[0], 0, sizeof (BitWord) * BITWORDS_PER_ELEMENT); } - ~SparseBitVectorElement() { - } - - // Copy ctor. - SparseBitVectorElement(const SparseBitVectorElement &RHS) { - ElementIndex = RHS.ElementIndex; - std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits); - } - - // Assignment - SparseBitVectorElement& operator=(const SparseBitVectorElement& RHS) { - ElementIndex = RHS.ElementIndex; - std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits); - - return *this; - } - // Comparison. bool operator==(const SparseBitVectorElement &RHS) const { if (ElementIndex != RHS.ElementIndex) diff --git a/include/llvm/ADT/alist.h b/include/llvm/ADT/alist.h deleted file mode 100644 index 1af3e4a5c0..0000000000 --- a/include/llvm/ADT/alist.h +++ /dev/null @@ -1,296 +0,0 @@ -//==- llvm/ADT/alist.h - Linked lists with hooks -----------------*- C++ -*-==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the alist class template, and related infrastructure. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ADT_ALIST_H -#define LLVM_ADT_ALIST_H - -#include "llvm/ADT/alist_node.h" -#include "llvm/ADT/STLExtras.h" - -namespace llvm { - -/// alist_iterator - An iterator class for alist. -/// -template<class T, class LargestT = T, class ValueT = T, - class NodeIterT = ilist_iterator<alist_node<T, LargestT> > > -class alist_iterator : public bidirectional_iterator<ValueT, ptrdiff_t> { -public: - typedef bidirectional_iterator<ValueT, ptrdiff_t> super; - typedef alist_node<T, LargestT> NodeTy; - -private: - /// NodeIter - The underlying iplist iterator that is being wrapped. - NodeIterT NodeIter; - -public: - typedef size_t size_type; - - // FIX for MSVC++. This should be reviewed more. - // typedef typename super::pointer pointer; - typedef ValueT* pointer; - - typedef typename super::reference reference; - - alist_iterator(NodeIterT NI) : NodeIter(NI) {} - alist_iterator(pointer EP) : NodeIter(NodeTy::getNode(EP)) {} - alist_iterator() : NodeIter() {} - - // This is templated so that we can allow constructing a const iterator from - // a nonconst iterator... - template<class V, class W, class X, class Y> - alist_iterator(const alist_iterator<V, W, X, Y> &RHS) - : NodeIter(RHS.getNodeIterUnchecked()) {} - - // This is templated so that we can allow assigning to a const iterator from - // a nonconst iterator... - template<class V, class W, class X, class Y> - const alist_iterator &operator=(const alist_iterator<V, W, X, Y> &RHS) { - NodeIter = RHS.getNodeIterUnchecked(); - return *this; - } - - operator pointer() const { return NodeIter->getElement((T*)0); } - - reference operator*() const { return *NodeIter->getElement((T*)0); } - pointer operator->() const { return &operator*(); } - - bool operator==(const alist_iterator &RHS) const { - return NodeIter == RHS.NodeIter; - } - bool operator!=(const alist_iterator &RHS) const { - return NodeIter != RHS.NodeIter; - } - - alist_iterator &operator--() { - --NodeIter; - return *this; - } - alist_iterator &operator++() { - ++NodeIter; - return *this; - } - alist_iterator operator--(int) { - alist_iterator tmp = *this; - --*this; - return tmp; - } - alist_iterator operator++(int) { - alist_iterator tmp = *this; - ++*this; - return tmp; - } - - NodeIterT getNodeIterUnchecked() const { return NodeIter; } -}; - -// do not implement. this is to catch errors when people try to use -// them as random access iterators -template<class T, class LargestT, class ValueT, class NodeIterT> -void operator-(int, alist_iterator<T, LargestT, ValueT, NodeIterT>); -template<class T, class LargestT, class ValueT, class NodeIterT> -void operator-(alist_iterator<T, LargestT, ValueT, NodeIterT>,int); - -template<class T, class LargestT, class ValueT, class NodeIterT> -void operator+(int, alist_iterator<T, LargestT, ValueT, NodeIterT>); -template<class T, class LargestT, class ValueT, class NodeIterT> -void operator+(alist_iterator<T, LargestT, ValueT, NodeIterT>,int); - -// operator!=/operator== - Allow mixed comparisons without dereferencing -// the iterator, which could very likely be pointing to end(). -template<class T, class V, class W, class X, class Y> -bool operator!=(T* LHS, const alist_iterator<V, W, X, Y> &RHS) { - return LHS != RHS.getNodeIterUnchecked().getNodePtrUnchecked() - ->getElement((T*)0); -} -template<class T, class V, class W, class X, class Y> -bool operator==(T* LHS, const alist_iterator<V, W, X, Y> &RHS) { - return LHS == RHS.getNodeIterUnchecked().getNodePtrUnchecked() - ->getElement((T*)0); -} - -// Allow alist_iterators to convert into pointers to a node automatically when -// used by the dyn_cast, cast, isa mechanisms... - -template<class From> struct simplify_type; - -template<class V, class W, class X, class Y> -struct simplify_type<alist_iterator<V, W, X, Y> > { - typedef alist_node<V, W> NodeTy; - typedef NodeTy* SimpleType; - - static SimpleType - getSimplifiedValue(const alist_iterator<V, W, X, Y> &Node) { - return &*Node; - } -}; -template<class V, class W, class X, class Y> -struct simplify_type<const alist_iterator<V, W, X, Y> > { - typedef alist_node<V, W> NodeTy; - typedef NodeTy* SimpleType; - - static SimpleType - getSimplifiedValue(const alist_iterator<V, W, X, Y> &Node) { - return &*Node; - } -}; - -/// Template traits for alist. By specializing this template class, you -/// can register custom actions to be run when a node is added to or removed -/// from an alist. A common use of this is to update parent pointers. -/// -template<class T, class LargestT = T> -class alist_traits { -public: - typedef alist_iterator<T, LargestT> iterator; - - void addNodeToList(T *) {} - void removeNodeFromList(T *) {} - void transferNodesFromList(alist_traits &, iterator, iterator) {} - void deleteNode(T *E) { delete alist_node<T, LargestT>::getNode(E); } -}; - -/// alist - This class is an ilist-style container that automatically -/// adds the next/prev pointers. It is designed to work in cooperation -/// with <llvm/Support/Recycler.h>. -/// -template<class T, class LargestT = T> -class alist { -public: - typedef alist_node<T, LargestT> NodeTy; - typedef typename ilist<NodeTy>::size_type size_type; - -private: - /// NodeListTraits - ilist traits for NodeList. - /// - struct NodeListTraits : ilist_traits<alist_node<T, LargestT> > { - alist_traits<T, LargestT> UserTraits; - - void addNodeToList(NodeTy *N) { - UserTraits.addNodeToList(N->getElement((T*)0)); - } - void removeNodeFromList(NodeTy *N) { - UserTraits.removeNodeFromList(N->getElement((T*)0)); - } - void transferNodesFromList(iplist<NodeTy, NodeListTraits> &L2, - ilist_iterator<NodeTy> first, - ilist_iterator<NodeTy> last) { - UserTraits.transferNodesFromList(L2.UserTraits, - iterator(first), - iterator(last)); - } - }; - - /// NodeList - Doubly-linked list of nodes that have constructed - /// contents and may be in active use. - /// - iplist<NodeTy, NodeListTraits> NodeList; - -public: - ~alist() { clear(); } - - typedef alist_iterator<T, LargestT, T, ilist_iterator<NodeTy> > - iterator; - typedef alist_iterator<T, LargestT, const T, ilist_iterator<const NodeTy> > - const_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - iterator begin() { return iterator(NodeList.begin()); } - iterator end() { return iterator(NodeList.end()); } - const_iterator begin() const { return const_iterator(NodeList.begin()); } - const_iterator end() const { return const_iterator(NodeList.end()); } - reverse_iterator rbegin() { return reverse_iterator(NodeList.rbegin()); } - reverse_iterator rend() { return reverse_iterator(NodeList.rend()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(NodeList.rbegin()); - } - const_reverse_iterator rend() const { - return const_reverse_iterator(NodeList.rend()); - } - - typedef T& reference; - typedef const T& const_reference; - reference front() { return *NodeList.front().getElement((T*)0); } - reference back() { return *NodeList.back().getElement((T*)0); } - const_reference front() const { return *NodeList.front().getElement((T*)0); } - const_reference back() const { return *NodeList.back().getElement((T*)0); } - - bool empty() const { return NodeList.empty(); } - size_type size() const { return NodeList.size(); } - - void push_front(T *E) { - NodeTy *N = alist_node<T, LargestT>::getNode(E); - assert(N->getPrev() == 0); - assert(N->getNext() == 0); - NodeList.push_front(N); - } - void push_back(T *E) { - NodeTy *N = alist_node<T, LargestT>::getNode(E); - assert(N->getPrev() == 0); - assert(N->getNext() == 0); - NodeList.push_back(N); - } - iterator insert(iterator I, T *E) { - NodeTy *N = alist_node<T, LargestT>::getNode(E); - assert(N->getPrev() == 0); - assert(N->getNext() == 0); - return iterator(NodeList.insert(I.getNodeIterUnchecked(), N)); - } - void splice(iterator where, alist &Other) { - NodeList.splice(where.getNodeIterUnchecked(), Other.NodeList); - } - void splice(iterator where, alist &Other, iterator From) { - NodeList.splice(where.getNodeIterUnchecked(), Other.NodeList, - From.getNodeIterUnchecked()); - } - void splice(iterator where, alist &Other, iterator From, - iterator To) { - NodeList.splice(where.getNodeIterUnchecked(), Other.NodeList, - From.getNodeIterUnchecked(), To.getNodeIterUnchecked()); - } - - void pop_front() { - erase(NodeList.begin()); - } - void pop_back() { - erase(prior(NodeList.end())); - } - iterator erase(iterator I) { - iterator Next = next(I); - NodeTy *N = NodeList.remove(I.getNodeIterUnchecked()); - NodeList.UserTraits.deleteNode(N->getElement((T*)0)); - return Next; - } - iterator erase(iterator first, iterator last) { - while (first != last) - first = erase(first); - return last; - } - - T *remove(T *E) { - NodeTy *N = alist_node<T, LargestT>::getNode(E); - return NodeList.remove(N)->getElement((T*)0); - } - - void clear() { - while (!empty()) pop_front(); - } - - alist_traits<T, LargestT> &getTraits() { - return NodeList.UserTraits; - } -}; - -} - -#endif diff --git a/include/llvm/ADT/alist_node.h b/include/llvm/ADT/alist_node.h deleted file mode 100644 index fcdf22c45c..0000000000 --- a/include/llvm/ADT/alist_node.h +++ /dev/null @@ -1,123 +0,0 @@ -//==- llvm/ADT/alist_node.h - Next/Prev helper class for alist ---*- C++ -*-==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the alist_node class template, which is used by the alist -// class template to provide next/prev pointers for arbitrary objects. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ADT_ALIST_NODE_H -#define LLVM_ADT_ALIST_NODE_H - -#include "llvm/ADT/ilist.h" -#include "llvm/Support/AlignOf.h" -#include "llvm/Support/DataTypes.h" -#include <cassert> - -namespace llvm { - -/// alist_node - This is a utility class used by alist. It holds prev and next -/// pointers for use with ilists, as well as storage for objects as large as -/// LargestT, that are in T's inheritance tree. -/// -template<class T, class LargestT = T> -class alist_node { - alist_node *Prev, *Next; - -public: - alist_node() : Prev(0), Next(0) {} - - alist_node *getPrev() const { return Prev; } - alist_node *getNext() const { return Next; } - void setPrev(alist_node *N) { Prev = N; } - void setNext(alist_node *N) { Next = N; } - - union { - char Bytes[sizeof(LargestT)]; - long long L; - void *P; - } Storage; - - template<class SubClass> - SubClass *getElement(SubClass *) { - assert(sizeof(SubClass) <= sizeof(LargestT)); - return reinterpret_cast<SubClass*>(&Storage.Bytes); - } - - template<class SubClass> - const SubClass *getElement(SubClass *) const { - assert(sizeof(SubClass) <= sizeof(LargestT)); - return reinterpret_cast<const SubClass*>(&Storage.Bytes); - } - - // This code essentially does offsetof, but actual offsetof hits an ICE in - // GCC 4.0 relating to offsetof being used inside a template. - static alist_node* getNode(T *D) { - return reinterpret_cast<alist_node*>(reinterpret_cast<char*>(D) - - (uintptr_t)&getNull()->Storage); - } - static const alist_node* getNode(const T *D) { - return reinterpret_cast<alist_node*>(reinterpret_cast<char*>(D) - - (uintptr_t)&getNull()->Storage); - } -private: - static alist_node* getNull() { return 0; } -}; - -// A specialization of ilist_traits for alist_nodes. -template<class T, class LargestT> -class ilist_traits<alist_node<T, LargestT> > { -public: - typedef alist_node<T, LargestT> NodeTy; - -protected: - // Allocate a sentinel inside the traits class. This works - // because iplist carries an instance of the traits class. - NodeTy Sentinel; - -public: - 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(); } - static const NodeTy *getNext(const NodeTy *N) { return N->getNext(); } - - static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); } - static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); } - - NodeTy *createSentinel() const { - assert(Sentinel.getPrev() == 0); - assert(Sentinel.getNext() == 0); - return const_cast<NodeTy*>(&Sentinel); - } - - void destroySentinel(NodeTy *N) { - assert(N == &Sentinel); N = N; - Sentinel.setPrev(0); - Sentinel.setNext(0); - } - - void addNodeToList(NodeTy *) {} - void removeNodeFromList(NodeTy *) {} - void transferNodesFromList(iplist<NodeTy, ilist_traits> &, - ilist_iterator<NodeTy> /*first*/, - ilist_iterator<NodeTy> /*last*/) {} - - // Ideally we wouldn't implement this, but ilist's clear calls it, - // which is called from ilist's destructor. We won't ever call - // either of those with a non-empty list, but statically this - // method needs to exist. - void deleteNode(NodeTy *) { assert(0); } - -private: - static NodeTy *createNode(const NodeTy &V); // do not implement -}; - -} - -#endif 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. // diff --git a/include/llvm/ADT/ilist_node.h b/include/llvm/ADT/ilist_node.h new file mode 100644 index 0000000000..9e60311706 --- /dev/null +++ b/include/llvm/ADT/ilist_node.h @@ -0,0 +1,43 @@ +//==-- llvm/ADT/ilist_node.h - Intrusive Linked List Helper ------*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the ilist_node class template, which is a convenient +// base class for creating classes that can be used with ilists. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_ILIST_NODE_H +#define LLVM_ADT_ILIST_NODE_H + +namespace llvm { + +template<typename NodeTy> +struct ilist_nextprev_traits; + +/// ilist_node - Base class that provides next/prev services for nodes +/// that use ilist_nextprev_traits or ilist_default_traits. +/// +template<typename NodeTy> +class ilist_node { +private: + friend struct ilist_nextprev_traits<NodeTy>; + NodeTy *Prev, *Next; + NodeTy *getPrev() { return Prev; } + NodeTy *getNext() { return Next; } + const NodeTy *getPrev() const { return Prev; } + const NodeTy *getNext() const { return Next; } + void setPrev(NodeTy *N) { Prev = N; } + void setNext(NodeTy *N) { Next = N; } +protected: + ilist_node() : Prev(0), Next(0) {} +}; + +} // End llvm namespace + +#endif diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index d9e45ce9a1..2dcc2bebe0 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -22,6 +22,7 @@ #include "llvm/ADT/iterator.h" #include "llvm/ADT/hash_map.h" #include "llvm/ADT/ilist.h" +#include "llvm/ADT/ilist_node.h" namespace llvm { @@ -33,7 +34,7 @@ class VAArgInst; class AliasSetTracker; class AliasSet; -class AliasSet { +class AliasSet : public ilist_node<AliasSet> { friend class AliasSetTracker; class PointerRec; @@ -118,12 +119,6 @@ class AliasSet { // Volatile - True if this alias set contains volatile loads or stores. bool Volatile : 1; - friend struct ilist_traits<AliasSet>; - AliasSet *getPrev() const { return Prev; } - AliasSet *getNext() const { return Next; } - void setPrev(AliasSet *P) { Prev = P; } - void setNext(AliasSet *N) { Next = N; } - void addRef() { ++RefCount; } void dropRef(AliasSetTracker &AST) { assert(RefCount >= 1 && "Invalid reference count detected!"); @@ -197,15 +192,15 @@ public: }; private: - // Can only be created by AliasSetTracker + // Can only be created by AliasSetTracker. Also, ilist creates one + // to serve as a sentinel. + friend struct ilist_sentinel_traits<AliasSet>; AliasSet() : PtrList(0), PtrListEnd(&PtrList), Forward(0), RefCount(0), AccessTy(NoModRef), AliasTy(MustAlias), Volatile(false) { } - AliasSet(const AliasSet &AS) { - assert(0 && "Copy ctor called!?!?!"); - abort(); - } + AliasSet(const AliasSet &AS); // do not implement + void operator=(const AliasSet &AS); // do not implement HashNodePair *getSomePointer() const { return PtrList; diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index d203a935bd..650bee3d10 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -27,12 +27,9 @@ template<typename ValueSubClass, typename ItemParentClass> /// in the body of a function, it represents the value of the actual argument /// the function was called with. /// @brief LLVM Argument representation -class Argument : public Value { // Defined in the Function.cpp file +class Argument : public Value, public ilist_node<Argument> { Function *Parent; - Argument *Prev, *Next; // Next and Prev links for our intrusive linked list - void setNext(Argument *N) { Next = N; } - void setPrev(Argument *N) { Prev = N; } friend class SymbolTableListTraits<Argument, Function>; void setParent(Function *parent); @@ -80,13 +77,6 @@ public: static inline bool classof(const Value *V) { return V->getValueID() == ArgumentVal; } - -private: - // getNext/Prev - Return the next or previous argument in the list. - Argument *getNext() { return Next; } - const Argument *getNext() const { return Next; } - Argument *getPrev() { return Prev; } - const Argument *getPrev() const { return Prev; } }; } // End llvm namespace diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 108f43a767..47478f2009 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -49,17 +49,15 @@ template<> struct ilist_traits<Instruction> /// modifying a program. However, the verifier will ensure that basic blocks /// are "well formed". /// @brief LLVM Basic Block Representation -class BasicBlock : public Value { // Basic blocks are data objects also +class BasicBlock : public Value, // Basic blocks are data objects also + public ilist_node<BasicBlock> { public: typedef iplist<Instruction> InstListType; private : InstListType InstList; - BasicBlock *Prev, *Next; // Next and Prev links for our intrusive linked list Function *Parent; void setParent(Function *parent); - void setNext(BasicBlock *N) { Next = N; } - void setPrev(BasicBlock *N) { Prev = N; } friend class SymbolTableListTraits<BasicBlock, Function>; BasicBlock(const BasicBlock &); // Do not implement @@ -204,14 +202,6 @@ public: BasicBlock *Obj = 0; return unsigned(reinterpret_cast<uintptr_t>(&Obj->InstList)); } - -private: - // getNext/Prev - Return the next or previous basic block in the list. Access - // these with Function::iterator. - BasicBlock *getNext() { return Next; } - const BasicBlock *getNext() const { return Next; } - BasicBlock *getPrev() { return Prev; } - const BasicBlock *getPrev() const { return Prev; } }; inline int diff --git a/include/llvm/Bitcode/Archive.h b/include/llvm/Bitcode/Archive.h index 91684c62e2..6ba11531dd 100644 --- a/include/llvm/Bitcode/Archive.h +++ b/include/llvm/Bitco |