LLVM 19.0.0git
ilist_node_base.h
Go to the documentation of this file.
1//===- llvm/ADT/ilist_node_base.h - Intrusive List Node Base -----*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_ADT_ILIST_NODE_BASE_H
10#define LLVM_ADT_ILIST_NODE_BASE_H
11
13
14namespace llvm {
15
16namespace ilist_detail {
17
18template <class NodeBase, bool EnableSentinelTracking> class node_base_prevnext;
19
20template <class NodeBase> class node_base_prevnext<NodeBase, false> {
21 NodeBase *Prev = nullptr;
22 NodeBase *Next = nullptr;
23
24public:
25 void setPrev(NodeBase *Prev) { this->Prev = Prev; }
26 void setNext(NodeBase *Next) { this->Next = Next; }
27 NodeBase *getPrev() const { return Prev; }
28 NodeBase *getNext() const { return Next; }
29
30 bool isKnownSentinel() const { return false; }
32};
33
34template <class NodeBase> class node_base_prevnext<NodeBase, true> {
35 PointerIntPair<NodeBase *, 1> PrevAndSentinel;
36 NodeBase *Next = nullptr;
37
38public:
39 void setPrev(NodeBase *Prev) { PrevAndSentinel.setPointer(Prev); }
40 void setNext(NodeBase *Next) { this->Next = Next; }
41 NodeBase *getPrev() const { return PrevAndSentinel.getPointer(); }
42 NodeBase *getNext() const { return Next; }
43
44 bool isSentinel() const { return PrevAndSentinel.getInt(); }
45 bool isKnownSentinel() const { return isSentinel(); }
46 void initializeSentinel() { PrevAndSentinel.setInt(true); }
47};
48
49template <class ParentTy> class node_base_parent {
50 ParentTy *Parent = nullptr;
51
52public:
53 void setNodeBaseParent(ParentTy *Parent) { this->Parent = Parent; }
54 inline const ParentTy *getNodeBaseParent() const { return Parent; }
55 inline ParentTy *getNodeBaseParent() { return Parent; }
56};
57template <> class node_base_parent<void> {};
58
59} // end namespace ilist_detail
60
61/// Base class for ilist nodes.
62///
63/// Optionally tracks whether this node is the sentinel.
64template <bool EnableSentinelTracking, class ParentTy>
66 ilist_node_base<EnableSentinelTracking, ParentTy>,
67 EnableSentinelTracking>,
68 public ilist_detail::node_base_parent<ParentTy> {};
69
70} // end namespace llvm
71
72#endif // LLVM_ADT_ILIST_NODE_BASE_H
basic Basic Alias true
static bool isSentinel(const DWARFDebugNames::AttributeEncoding &AE)
This file defines the PointerIntPair class.
PointerIntPair - This class implements a pair of a pointer and small integer.
const ParentTy * getNodeBaseParent() const
void setNodeBaseParent(ParentTy *Parent)
Base class for ilist nodes.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18