14#ifndef LLVM_ADT_IMMUTABLEMAP_H
15#define LLVM_ADT_IMMUTABLEMAP_H
28template <
typename T,
typename S>
62template <
typename KeyT,
typename ValT,
63 typename ValInfo = ImutKeyValueInfo<KeyT, ValT>,
64 bool Canonicalize =
true>
100 TreeTy *
T = F.add(Old.
Root.get(), std::pair<key_type, data_type>(
K,
D));
101 if constexpr (Canonicalize)
118 template <
typename CombineFn>
120 CombineFn
Combine,
bool KeepUnmatched,
121 bool SkipShared =
false) {
122 static_assert(!Canonicalize,
123 "mergeWith does not canonicalize the nodes it creates");
125 KeepUnmatched, SkipShared));
130 if constexpr (Canonicalize)
150 if constexpr (Canonicalize)
158 if constexpr (Canonicalize)
196 iterator() =
default;
210 if (
T)
return &
T->getValue().second;
228 return Root ?
Root->getHeight() : 0;
232 ID.AddPointer(M.Root.get());
241template <
typename KeyT,
typename ValT,
242typename ValInfo = ImutKeyValueInfo<KeyT,ValT>>
268 :
Root(
X.getRootWithoutRetain()),
Factory(
F.getTreeFactory()) {}
284 Factory->add(
Root.get(), std::pair<key_type, data_type>(
K,
D));
328 iterator() =
default;
342 if (
T)
return &
T->getValue().second;
360 return Root ?
Root->getHeight() : 0;
364 ID.AddPointer(M.Root.get());
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ATTRIBUTE_WARN_UNUSED
This file defines a hash set that can be used to remove duplication of nodes in a graph.
This file defines the ImutAVLTree and ImmutableSet classes.
static constexpr Value * getValue(Ty &ValueOrUse)
This class is used to gather all the unique data bits of a node.
key_type_ref getKey() const
data_type_ref getData() const
friend class ImmutableMapRef
unsigned getHeight() const
ImmutableMap< KeyT, ValT > asImmutableMap() const
static ImmutableMapRef getEmptyMap(FactoryTy *F)
void Profile(FoldingSetNodeID &ID) const
bool operator!=(const ImmutableMapRef &RHS) const
bool contains(key_type_ref K) const
static void Profile(FoldingSetNodeID &ID, const ImmutableMapRef &M)
typename ValInfo::data_type data_type
typename ValInfo::data_type_ref data_type_ref
typename ValInfo::key_type key_type
IntrusiveRefCntPtr< TreeTy > Root
ImutAVLTree< ValInfo > TreeTy
typename ValInfo::value_type_ref value_type_ref
bool operator==(const ImmutableMapRef &RHS) const
ImmutableMapRef remove(key_type_ref K) const
typename ValInfo::key_type_ref key_type_ref
value_type * getMaxElement() const
Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ordering of keys...
ImmutableMapRef add(key_type_ref K, data_type_ref D) const
typename ValInfo::value_type value_type
ImmutableMapRef(const TreeTy *R, FactoryTy *F)
Constructs a map from a pointer to a tree root.
data_type * lookup(key_type_ref K) const
ImmutableMapRef(const ImmutableMap< KeyT, ValT > &X, typename ImmutableMap< KeyT, ValT >::Factory &F)
typename TreeTy::Factory FactoryTy
TreeTy::Factory * getTreeFactory() const
ImmutableMap getEmptyMap()
ImmutableMap remove(ImmutableMap Old, key_type_ref K)
Factory(BumpPtrAllocator &Alloc)
Factory & operator=(const Factory &)=delete
ImmutableMap mergeWith(ImmutableMap A, ImmutableMap B, CombineFn Combine, bool KeepUnmatched, bool SkipShared=false)
Merges A and B in a single traversal (see ImutAVLFactory::mergeTrees), sharing subtrees the two maps ...
ImmutableMap add(ImmutableMap Old, key_type_ref K, data_type_ref D)
Factory(const Factory &)=delete
key_type_ref getKey() const
data_type_ref getData() const
friend class ImmutableMap
typename ValInfo::data_type_ref data_type_ref
TreeTy * getRootWithoutRetain() const
typename ValInfo::key_type_ref key_type_ref
typename ValInfo::value_type_ref value_type_ref
value_type * getMaxElement() const
Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ordering of keys...
typename ValInfo::key_type key_type
typename ValInfo::value_type value_type
typename ValInfo::data_type data_type
void Profile(FoldingSetNodeID &ID) const
bool operator!=(const ImmutableMap &RHS) const
ImmutableMap(const TreeTy *R)
Constructs a map from a pointer to a tree root.
bool contains(key_type_ref K) const
unsigned getHeight() const
data_type * lookup(key_type_ref K) const
IntrusiveRefCntPtr< TreeTy > Root
bool operator==(const ImmutableMap &RHS) const
Compares two maps for equality.
ImutAVLTree< ValInfo, Canonicalize > TreeTy
static void Profile(FoldingSetNodeID &ID, const ImmutableMap &M)
ImutAVLFactory< ValInfo, Canonicalize > Factory
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is an optimization pass for GlobalISel generic memory operations.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
ImutAVLValueIterator()=default
static bool isLess(key_type_ref LHS, key_type_ref RHS)
static bool isEqual(key_type_ref LHS, key_type_ref RHS)
Traits class used by ImmutableMap.
const value_type & value_type_ref
static void Profile(FoldingSetNodeID &ID, value_type_ref V)
static bool isLess(key_type_ref L, key_type_ref R)
static key_type_ref KeyOfValue(value_type_ref V)
const std::pair< T, S > value_type
static data_type_ref DataOfValue(value_type_ref V)
static bool isDataEqual(data_type_ref L, data_type_ref R)
static bool isEqual(key_type_ref L, key_type_ref R)
static void Profile(FoldingSetNodeID &ID, value_type_ref X)