14#ifndef LLVM_ADT_IMMUTABLEMAP_H
15#define LLVM_ADT_IMMUTABLEMAP_H
27template <
typename T,
typename S>
61template <
typename KeyT,
typename ValT,
62 typename ValInfo = ImutKeyValueInfo<KeyT, ValT>,
63 bool Canonicalize =
true>
99 TreeTy *
T = F.add(Old.
Root.get(), std::pair<key_type, data_type>(K,
D));
100 if constexpr (Canonicalize)
108 if constexpr (Canonicalize)
120 return Root ?
Root->contains(K) :
false;
128 if constexpr (Canonicalize)
136 if constexpr (Canonicalize)
174 iterator() =
default;
188 if (
T)
return &
T->getValue().second;
206 return Root ?
Root->getHeight() : 0;
210 ID.AddPointer(M.Root.get());
219template <
typename KeyT,
typename ValT,
220typename ValInfo = ImutKeyValueInfo<KeyT,ValT>>
246 :
Root(
X.getRootWithoutRetain()),
Factory(
F.getTreeFactory()) {}
262 Factory->add(
Root.get(), std::pair<key_type, data_type>(K,
D));
272 return Root ?
Root->contains(K) :
false;
306 iterator() =
default;
320 if (
T)
return &
T->getValue().second;
338 return Root ?
Root->getHeight() : 0;
342 ID.AddPointer(M.Root.get());
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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 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...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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)