LLVM: include/llvm/ADT/ilist.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef LLVM_ADT_ILIST_H
25#define LLVM_ADT_ILIST_H
26
28#include
29#include
30#include
31
32namespace llvm {
33
34
35
36
37
38
39
40
44
45
46
47
48
49
50
51
52
53
54
55
56
60
61
62
63
64
68
69
70
71 template
73 Iterator ) {
74 (void)OldList;
75 }
76};
77
78
79
80
81
82template
85
86
87
88
89template
91
92
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109template <class IntrusiveListT, class TraitsT>
112
113public:
114 using pointer = typename base_list_type::pointer;
115 using const_pointer = typename base_list_type::const_pointer;
116 using reference = typename base_list_type::reference;
118 using value_type = typename base_list_type::value_type;
119 using size_type = typename base_list_type::size_type;
121 using iterator = typename base_list_type::iterator;
125 typename base_list_type::const_reverse_iterator;
126
127private:
130
131public:
133
136
141 *static_cast<TraitsT *>(this) = std::move(static_cast<TraitsT &>(X));
144 return *this;
145 }
146
148
149
151
152 using base_list_type::begin;
153 using base_list_type::end;
154 using base_list_type::rbegin;
155 using base_list_type::rend;
156 using base_list_type::empty;
157 using base_list_type::front;
158 using base_list_type::back;
159
161 assert(0 && "Swap does not use list traits callback correctly yet!");
162 base_list_type::swap(RHS);
163 }
164
166 this->addNodeToList(New);
167 return base_list_type::insert(where, *New);
168 }
169
173
175 if (empty())
176 return insert(begin(), New);
177 else
178 return insert(++where, New);
179 }
180
181
187
190 this->removeNodeFromList(Node);
191 base_list_type::remove(*Node);
193 }
194
197 return remove(MutIt);
198 }
199
202
203
205 this->deleteNode(remove(where));
206 return where;
207 }
208
211
212
213
214
215
216
218
219private:
220
221
222
224 if (position == last)
225 return;
226
227
228 this->transferNodesFromList(L2, first, last);
229
230 base_list_type::splice(position, L2, first, last);
231 }
232
233public:
234
235
236
237
238 using base_list_type::size;
239
241 while (first != last)
242 first = erase(first);
243 return last;
244 }
245
247
248
252 assert(!empty() && "pop_front() on empty list!");
254 }
256 assert(!empty() && "pop_back() on empty list!");
258 }
259
260
261 template void insert(iterator where, InIt first, InIt last) {
262 for (; first != last; ++first) insert(where, *first);
263 }
264
265
267 if (!L2.empty())
268 transfer(where, L2, L2.begin(), L2.end());
269 }
271 iterator last = first; ++last;
272 if (where == first || where == last) return;
273 transfer(where, L2, first, last);
274 }
276 if (first != last) transfer(where, L2, first, last);
277 }
284
285 template
287 if (this == &Right)
288 return;
289 this->transferNodesFromList(Right, Right.begin(), Right.end());
290 base_list_type::merge(Right, comp);
291 }
293
294 using base_list_type::sort;
295
296
299 if (I == begin())
300 return nullptr;
301 return &*std::prev(I);
302 }
303
307
308
310 auto Next = std::next(N.getIterator());
311 if (Next == end())
312 return nullptr;
313 return &*Next;
314 }
315
319};
320
321
322
323
324
325
326template <class T, class... Options>
328 : public iplist_impl<simple_ilist<T, Options...>, ilist_traits> {
330
331public:
333
336
339 *static_cast<iplist_impl_type *>(this) = std::move(X);
340 return *this;
341 }
342};
343
345
346}
347
348namespace std {
349
350
351 template
353 Left.swap(Right);
354 }
355
356}
357
358#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
A wrapper around an intrusive list with callbacks and non-intrusive ownership.
Definition ilist.h:110
iterator erase(reference IT)
Definition ilist.h:210
iterator erase(iterator first, iterator last)
Definition ilist.h:240
void splice(iterator where, iplist_impl &L2, iterator first, iterator last)
Definition ilist.h:275
void splice(iterator where, iplist_impl &L2, reference N)
Definition ilist.h:278
void splice(iterator where, iplist_impl &L2)
Definition ilist.h:266
void pop_back()
Definition ilist.h:255
typename base_list_type::reference reference
Definition ilist.h:116
void push_back(pointer val)
Definition ilist.h:250
void swap(iplist_impl &RHS)
Definition ilist.h:160
void insert(iterator where, InIt first, InIt last)
Definition ilist.h:261
iplist_impl(const iplist_impl &)=delete
typename base_list_type::const_reverse_iterator const_reverse_iterator
Definition ilist.h:124
typename base_list_type::reverse_iterator reverse_iterator
Definition ilist.h:123
pointer getPrevNode(reference N) const
Get the previous node, or nullptr for the list head.
Definition ilist.h:297
iterator erase(pointer IT)
Definition ilist.h:209
typename base_list_type::value_type value_type
Definition ilist.h:118
pointer getNextNode(reference N) const
Get the next node, or nullptr for the list tail.
Definition ilist.h:309
const_pointer getNextNode(const_reference N) const
Get the next node, or nullptr for the list tail.
Definition ilist.h:316
iterator insert(iterator where, const_reference New)
Definition ilist.h:170
~iplist_impl()
Definition ilist.h:147
typename base_list_type::iterator iterator
Definition ilist.h:121
void pop_front()
Definition ilist.h:251
iterator erase(iterator where)
Definition ilist.h:204
pointer remove(iterator &IT)
Definition ilist.h:188
typename base_list_type::size_type size_type
Definition ilist.h:119
iplist_impl(iplist_impl &&X)
Definition ilist.h:137
void splice(iterator where, iplist_impl &L2, iterator first)
Definition ilist.h:270
iterator insertAfter(iterator where, pointer New)
Definition ilist.h:174
void splice(iterator where, iplist_impl &L2, pointer N)
Definition ilist.h:281
typename base_list_type::difference_type difference_type
Definition ilist.h:120
void push_front(pointer val)
Definition ilist.h:249
void clearAndLeakNodesUnsafely()
Remove all nodes from the list like clear(), but do not call removeNodeFromList() or deleteNode().
Definition ilist.h:217
iplist_impl & operator=(iplist_impl &&X)
Definition ilist.h:140
iterator insert(iterator where, pointer New)
Definition ilist.h:165
pointer remove(const iterator &IT)
Definition ilist.h:195
pointer remove(pointer IT)
Definition ilist.h:200
void merge(iplist_impl &Right)
Definition ilist.h:292
void merge(iplist_impl &Right, Compare comp)
Definition ilist.h:286
typename base_list_type::pointer pointer
Definition ilist.h:114
iplist_impl & operator=(const iplist_impl &)=delete
size_type max_size() const
Definition ilist.h:150
typename base_list_type::const_pointer const_pointer
Definition ilist.h:115
void cloneFrom(const iplist_impl &L2, Cloner clone)
Clone another list.
Definition ilist.h:182
typename base_list_type::const_iterator const_iterator
Definition ilist.h:122
pointer remove(reference IT)
Definition ilist.h:201
const_pointer getPrevNode(const_reference N) const
Get the previous node, or nullptr for the list head.
Definition ilist.h:304
typename base_list_type::const_reference const_reference
Definition ilist.h:117
void clear()
Definition ilist.h:246
iplist(iplist &&X)
Definition ilist.h:337
iplist & operator=(iplist &&X)
Definition ilist.h:338
iplist & operator=(const iplist &X)=delete
iplist(const iplist &X)=delete
This is an optimization pass for GlobalISel generic memory operations.
iplist< T, Options... > ilist
Definition ilist.h:344
FunctionAddr VTableAddr Next
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Use delete by default for iplist and ilist.
Definition ilist.h:41
static void deleteNode(NodeTy *V)
Definition ilist.h:42
Callbacks do nothing by default in iplist and ilist.
Definition ilist.h:65
void removeNodeFromList(NodeTy *)
Definition ilist.h:67
void addNodeToList(NodeTy *)
When an MBB is added to an MF, we need to update the parent pointer of the MBB, the MBB numbering,...
Definition ilist.h:66
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
Callback before transferring nodes to this list.
Definition ilist.h:72
Custom traits to do nothing on deletion.
Definition ilist.h:57
static void deleteNode(NodeTy *V)
Definition ilist.h:58
A fragment for template traits for intrusive list that provides default node related operations.
Definition ilist.h:84
Template traits for intrusive list.
Definition ilist.h:90