llvm.org GIT mirror llvm / 2600ca8
re-committing yesterday's r79938. This time there is no additional include of llvm/Config/config.h at all. Instead I use a hard-coded preprecessor symbol: LLVM_COMPACTIFY_SENTINELS (should this work on the self-hosting buildbot, then cleanups come next) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80035 91177308-0d34-0410-b5e6-96231b3b80d8 Gabor Greif 10 years ago
7 changed file(s) with 63 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
3939
4040 #include "llvm/ADT/iterator.h"
4141 #include
42
43 #undef LLVM_COMPACTIFY_SENTINELS
44 /// @brief activate small sentinel structs
45 /// Comment out if you want better debuggability
46 /// of ilist<> end() iterators.
47 /// See also llvm/ADT/ilist_node.h, where the
48 /// same change must be made.
49 ///
50 #define LLVM_COMPACTIFY_SENTINELS 1
51
52 #if defined(LLVM_COMPACTIFY_SENTINELS) && LLVM_COMPACTIFY_SENTINELS
53 # define sentinel_tail_assert(COND)
54 #else
55 # define sentinel_tail_assert(COND) assert(COND)
56 #endif
4257
4358 namespace llvm {
4459
188203
189204 // Accessors...
190205 operator pointer() const {
191 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
206 sentinel_tail_assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
192207 return NodePtr;
193208 }
194209
195210 reference operator*() const {
196 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
211 sentinel_tail_assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
197212 return *NodePtr;
198213 }
199214 pointer operator->() const { return &operator*(); }
214229 }
215230 ilist_iterator &operator++() { // preincrement - Advance
216231 NodePtr = Traits::getNext(NodePtr);
217 assert(NodePtr && "++'d off the end of an ilist!");
232 sentinel_tail_assert(NodePtr && "++'d off the end of an ilist!");
218233 return *this;
219234 }
220235 ilist_iterator operator--(int) { // postdecrement operators...
1414 #ifndef LLVM_ADT_ILIST_NODE_H
1515 #define LLVM_ADT_ILIST_NODE_H
1616
17 #undef LLVM_COMPACTIFY_SENTINELS
18 /// @brief activate small sentinel structs
19 /// Comment out if you want better debuggability
20 /// of ilist<> end() iterators.
21 /// See also llvm/ADT/ilist.h, where the
22 /// same change must be made.
23 ///
24 #define LLVM_COMPACTIFY_SENTINELS 1
25
1726 namespace llvm {
1827
1928 template
20 struct ilist_nextprev_traits;
29 struct ilist_traits;
30
31 /// ilist_half_node - Base class that provides prev services for sentinels.
32 ///
33 template
34 class ilist_half_node {
35 friend struct ilist_traits;
36 NodeTy *Prev;
37 protected:
38 NodeTy *getPrev() { return Prev; }
39 const NodeTy *getPrev() const { return Prev; }
40 void setPrev(NodeTy *P) { Prev = P; }
41 ilist_half_node() : Prev(0) {}
42 };
2143
2244 template
23 struct ilist_traits;
45 struct ilist_nextprev_traits;
2446
2547 /// ilist_node - Base class that provides next/prev services for nodes
2648 /// that use ilist_nextprev_traits or ilist_default_traits.
2749 ///
2850 template
29 class ilist_node {
30 private:
51 class ilist_node : ilist_half_node {
3152 friend struct ilist_nextprev_traits;
3253 friend struct ilist_traits;
33 NodeTy *Prev, *Next;
34 NodeTy *getPrev() { return Prev; }
54 NodeTy *Next;
3555 NodeTy *getNext() { return Next; }
36 const NodeTy *getPrev() const { return Prev; }
3756 const NodeTy *getNext() const { return Next; }
38 void setPrev(NodeTy *N) { Prev = N; }
3957 void setNext(NodeTy *N) { Next = N; }
4058 protected:
41 ilist_node() : Prev(0), Next(0) {}
59 ilist_node() : Next(0) {}
4260 };
61
62 /// When assertions are off, the Next field of sentinels
63 /// will not be accessed. So it is not necessary to allocate
64 /// space for it. The following macro selects the most
65 /// efficient traits class. The LLVM_COMPACTIFY_SENTINELS
66 /// preprocessor symbol controls this.
67 ///
68 #if defined(LLVM_COMPACTIFY_SENTINELS) && LLVM_COMPACTIFY_SENTINELS
69 # define ILIST_NODE ilist_half_node
70 #else
71 # define ILIST_NODE ilist_node
72 #endif
4373
4474 } // End llvm namespace
4575
4646 Instruction *ensureHead(Instruction*) const { return createSentinel(); }
4747 static void noteHead(Instruction*, Instruction*) {}
4848 private:
49 mutable ilist_node Sentinel;
49 mutable ILIST_NODE Sentinel;
5050 };
5151
5252 /// This represents a single basic block in LLVM. A basic block is simply a
2525 template <>
2626 struct ilist_traits : public ilist_default_traits {
2727 private:
28 mutable ilist_node Sentinel;
28 mutable ILIST_NODE Sentinel;
2929
3030 // this is only set by the MachineBasicBlock owning the LiveList
3131 friend class MachineBasicBlock;
3737 template <>
3838 struct ilist_traits
3939 : public ilist_default_traits {
40 mutable ilist_node Sentinel;
40 mutable ILIST_NODE Sentinel;
4141 public:
4242 MachineBasicBlock *createSentinel() const {
4343 return static_cast(&Sentinel);
3636
3737 template<> struct ilist_traits : public ilist_default_traits {
3838 private:
39 mutable ilist_node Sentinel;
39 mutable ILIST_NODE Sentinel;
4040 public:
4141 SDNode *createSentinel() const {
4242 return static_cast(&Sentinel);
4444
4545 static ValueSymbolTable *getSymTab(Function *ItemParent);
4646 private:
47 mutable ilist_node Sentinel;
47 mutable ILIST_NODE Sentinel;
4848 };
4949
5050 template<> struct ilist_traits
6161
6262 static ValueSymbolTable *getSymTab(Function *ItemParent);
6363 private:
64 mutable ilist_node Sentinel;
64 mutable ILIST_NODE Sentinel;
6565 };
6666
6767 class Function : public GlobalValue,