9#ifndef LLVM_ADT_ILIST_ITERATOR_H
10#define LLVM_ADT_ILIST_ITERATOR_H
20namespace ilist_detail {
26 using pointer =
typename OptionsT::pointer;
33 using pointer =
typename OptionsT::const_pointer;
34 using reference =
typename OptionsT::const_reference;
43 template <
class T>
static void increment(
T *&
I) {
I = Access::getNext(*
I); }
44 template <
class T>
static void decrement(
T *&
I) {
I = Access::getPrev(*
I); }
49 template <
class T>
static void increment(
T *&
I) {
I = Access::getPrev(*
I); }
50 template <
class T>
static void decrement(
T *&
I) {
I = Access::getNext(*
I); }
56template <
class IteratorTy,
class ParentTy,
bool IsConst>
58template <
class IteratorTy,
class ParentTy>
62 return static_cast<IteratorTy *
>(
this)->NodePtr->getParent();
65template <
class IteratorTy,
class ParentTy>
69 return static_cast<IteratorTy *
>(
this)->NodePtr->getParent();
72template <
class IteratorTy>
74template <
class IteratorTy>
80template <
class OptionsT,
bool IsReverse,
bool IsConst>
83 ilist_iterator<OptionsT, IsReverse, IsConst>,
84 typename OptionsT::parent_ty, IsConst> {
90 typename OptionsT::parent_ty, IsConst>;
105 using node_pointer =
typename Traits::node_pointer;
106 using node_reference =
typename Traits::node_reference;
108 node_pointer NodePtr =
nullptr;
120 template <
bool RHSIsConst>
122 std::enable_if_t<IsConst || !RHSIsConst, void *> =
nullptr)
123 : NodePtr(
RHS.NodePtr) {}
127 template <
bool RHSIsConst>
128 std::enable_if_t<IsConst || !RHSIsConst, ilist_iterator &>
130 NodePtr =
RHS.NodePtr;
162 false>::node_reference>(*NodePtr));
168 assert(!NodePtr->isKnownSentinel());
175 return LHS.NodePtr ==
RHS.NodePtr;
178 return LHS.NodePtr !=
RHS.NodePtr;
183 NodePtr = IsReverse ? NodePtr->getNext() : NodePtr->getPrev();
187 NodePtr = IsReverse ? NodePtr->getPrev() : NodePtr->getNext();
204 node_pointer
getNodePtr()
const {
return static_cast<node_pointer
>(NodePtr); }
207 bool isEnd()
const {
return NodePtr ? NodePtr->isSentinel() :
false; }
213template <
class OptionsT,
bool IsReverse,
bool IsConst>
217 ilist_iterator_w_bits<OptionsT, IsReverse, IsConst>,
218 typename OptionsT::parent_ty, IsConst> {
224 typename OptionsT::parent_ty, IsConst>;
239 using node_pointer =
typename Traits::node_pointer;
240 using node_reference =
typename Traits::node_reference;
242 node_pointer NodePtr =
nullptr;
246 mutable bool HeadInclusiveBit =
false;
249 mutable bool TailInclusiveBit =
false;
263 template <
bool RHSIsConst>
266 std::enable_if_t<IsConst || !RHSIsConst, void *> =
nullptr)
267 : NodePtr(
RHS.NodePtr) {
268 HeadInclusiveBit =
RHS.HeadInclusiveBit;
269 TailInclusiveBit =
RHS.TailInclusiveBit;
274 template <
bool RHSIsConst>
275 std::enable_if_t<IsConst || !RHSIsConst, ilist_iterator_w_bits &>
277 NodePtr =
RHS.NodePtr;
278 HeadInclusiveBit =
RHS.HeadInclusiveBit;
279 TailInclusiveBit =
RHS.TailInclusiveBit;
311 false>::node_reference>(
313 New.HeadInclusiveBit = HeadInclusiveBit;
314 New.TailInclusiveBit = TailInclusiveBit;
322 assert(!NodePtr->isKnownSentinel());
330 return LHS.NodePtr ==
RHS.NodePtr;
334 return LHS.NodePtr !=
RHS.NodePtr;
339 NodePtr = IsReverse ? NodePtr->getNext() : NodePtr->getPrev();
340 HeadInclusiveBit =
false;
341 TailInclusiveBit =
false;
345 NodePtr = IsReverse ? NodePtr->getPrev() : NodePtr->getNext();
346 HeadInclusiveBit =
false;
347 TailInclusiveBit =
false;
364 node_pointer
getNodePtr()
const {
return static_cast<node_pointer
>(NodePtr); }
367 bool isEnd()
const {
return NodePtr ? NodePtr->isSentinel() :
false; }
371 void setHeadBit(
bool SetBit)
const { HeadInclusiveBit = SetBit; }
372 void setTailBit(
bool SetBit)
const { TailInclusiveBit = SetBit; }
375template <
typename From>
struct simplify_type;
381template <
class OptionsT,
bool IsConst>
388template <
class OptionsT,
bool IsConst>
390 :
simplify_type<ilist_iterator<OptionsT, false, IsConst>> {};
393template <
class OptionsT,
bool IsConst>
400template <
class OptionsT,
bool IsConst>
402 :
simplify_type<ilist_iterator_w_bits<OptionsT, false, IsConst>> {};
const MachineOperand & RHS
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ParentTy * getNodeParent()
const ParentTy * getNodeParent() const
Mixin class used to add a getNodeParent() function to iterators iff the list uses ilist_parent,...
Iterator for intrusive lists based on ilist_node.
ilist_iterator_w_bits()=default
ilist_iterator_w_bits< OptionsT, !IsReverse, IsConst > getReverse() const
Get a reverse iterator to the same node.
ilist_iterator_w_bits(reference NR)
ilist_iterator_w_bits & operator--()
typename OptionsT::const_pointer const_pointer
ilist_iterator_w_bits(const ilist_iterator_w_bits< OptionsT, IsReverse, RHSIsConst > &RHS, std::enable_if_t< IsConst||!RHSIsConst, void * >=nullptr)
pointer operator->() const
ilist_iterator_w_bits operator--(int)
ilist_iterator_w_bits(pointer NP)
typename OptionsT::const_reference const_reference
ilist_iterator_w_bits(node_reference N)
Create from an ilist_node.
std::bidirectional_iterator_tag iterator_category
ilist_iterator_w_bits< OptionsT, IsReverse, false > getNonConst() const
Const-cast.
node_pointer getNodePtr() const
Get the underlying ilist_node.
ilist_iterator_w_bits(const ilist_iterator_w_bits< OptionsT, !IsReverse, IsConst > &RHS)
Explicit conversion between forward/reverse iterators.
reference operator*() const
typename Traits::pointer pointer
ilist_iterator_w_bits & operator++()
friend bool operator==(const ilist_iterator_w_bits &LHS, const ilist_iterator_w_bits &RHS)
bool isEnd() const
Check for end. Only valid if ilist_sentinel_tracking<true>.
typename Traits::value_type value_type
ilist_iterator_w_bits operator++(int)
std::enable_if_t< IsConst||!RHSIsConst, ilist_iterator_w_bits & > operator=(const ilist_iterator_w_bits< OptionsT, IsReverse, RHSIsConst > &RHS)
void setTailBit(bool SetBit) const
void setHeadBit(bool SetBit) const
friend bool operator!=(const ilist_iterator_w_bits &LHS, const ilist_iterator_w_bits &RHS)
typename Traits::reference reference
Iterator for intrusive lists based on ilist_node.
typename Traits::reference reference
std::bidirectional_iterator_tag iterator_category
ilist_iterator(reference NR)
bool isEnd() const
Check for end. Only valid if ilist_sentinel_tracking<true>.
node_pointer getNodePtr() const
Get the underlying ilist_node.
friend bool operator!=(const ilist_iterator &LHS, const ilist_iterator &RHS)
ilist_iterator operator--(int)
typename OptionsT::const_pointer const_pointer
ilist_iterator< OptionsT, !IsReverse, IsConst > getReverse() const
Get a reverse iterator to the same node.
reference operator*() const
ilist_iterator< OptionsT, IsReverse, false > getNonConst() const
Const-cast.
ilist_iterator & operator++()
typename Traits::value_type value_type
ilist_iterator(const ilist_iterator< OptionsT, !IsReverse, IsConst > &RHS)
Explicit conversion between forward/reverse iterators.
ilist_iterator(const ilist_iterator< OptionsT, IsReverse, RHSIsConst > &RHS, std::enable_if_t< IsConst||!RHSIsConst, void * >=nullptr)
friend bool operator==(const ilist_iterator &LHS, const ilist_iterator &RHS)
pointer operator->() const
ilist_iterator operator++(int)
ilist_iterator(node_reference N)
Create from an ilist_node.
ilist_iterator(pointer NP)
std::enable_if_t< IsConst||!RHSIsConst, ilist_iterator & > operator=(const ilist_iterator< OptionsT, IsReverse, RHSIsConst > &RHS)
typename OptionsT::const_reference const_reference
ilist_iterator & operator--()
typename Traits::pointer pointer
Implementation for an ilist node.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This is an optimization pass for GlobalISel generic memory operations.
static void decrement(T *&I)
static void increment(T *&I)
static void increment(T *&I)
static void decrement(T *&I)
typename OptionsT::value_type value_type
typename OptionsT::pointer pointer
typename OptionsT::reference reference
typename OptionsT::const_pointer pointer
const typename OptionsT::value_type value_type
typename OptionsT::const_reference reference
Find const-correct node types.
An access class for ilist_node private API.
static pointer getValuePtr(node_type *N)
typename iterator::pointer SimpleType
static SimpleType getSimplifiedValue(const iterator &Node)
static SimpleType getSimplifiedValue(const iterator &Node)
typename iterator::pointer SimpleType
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...