25#ifndef LLVM_IR_VALUEMAP_H 
   26#define LLVM_IR_VALUEMAP_H 
   45template <
typename KeyT, 
typename ValueT, 
typename Config>
 
   47template <
typename DenseMapT, 
typename KeyT, 
bool IsConst>
 
   53template <
typename KeyT, 
typename MutexT = sys::Mutex> 
struct ValueMapConfig {
 
   66  template <
typename ExtraDataT>
 
   68  template <
typename ExtraDataT>
 
   75  template <
typename ExtraDataT>
 
 
   82template <
typename KeyT, 
typename ValueT,
 
   83          typename Config = ValueMapConfig<KeyT>>
 
   92  using ExtraData = 
typename Config::ExtraData;
 
   95  std::optional<MDMapT> MDMap;
 
  105      : Map(NumInitBuckets), Data() {}
 
 
  106  explicit ValueMap(
const ExtraData &Data, 
unsigned NumInitBuckets = 64)
 
  107      : Map(NumInitBuckets), Data(Data) {}
 
 
  121  std::optional<MDMapT> &
getMDMap() { 
return MDMap; }
 
  129    auto Where = MDMap->find(
MD);
 
  130    if (Where == MDMap->end())
 
  132    return Where->second.get();
 
 
  143  bool empty()
 const { 
return Map.empty(); }
 
  157    return Map.find_as(Val) == Map.end() ? 0 : 1;
 
 
  169    return I != Map.end() ? 
I->second : ValueT();
 
 
  175  std::pair<iterator, bool> 
insert(
const std::pair<KeyT, ValueT> &KV) {
 
  176    auto MapResult = Map.insert(std::make_pair(Wrap(KV.first), KV.second));
 
  177    return std::make_pair(
iterator(MapResult.first), MapResult.second);
 
 
  180  std::pair<iterator, bool> 
insert(std::pair<KeyT, ValueT> &&KV) {
 
  182        Map.insert(std::make_pair(Wrap(KV.first), std::move(KV.second)));
 
  183    return std::make_pair(
iterator(MapResult.first), MapResult.second);
 
 
  187  template <
typename InputIt> 
void insert(InputIt 
I, InputIt 
E) {
 
 
  203    return Map.FindAndConstruct(Wrap(
Key));
 
 
  212    return Map.isPointerIntoBucketsArray(
Ptr);
 
 
  219    return Map.getPointerIntoBucketsArray();
 
 
  226  ValueMapCVH Wrap(
KeyT key)
 const {
 
  231    return ValueMapCVH(key, 
const_cast<ValueMap *
>(
this));
 
 
  237template <
typename KeyT, 
typename ValueT, 
typename Config>
 
  243  using KeySansPointerT = std::remove_pointer_t<KeyT>;
 
  247  ValueMapCallbackVH(
KeyT Key, ValueMapT *Map)
 
  259    ValueMapCallbackVH Copy(*
this);
 
  260    typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
 
  261    std::unique_lock<typename Config::mutex_type> Guard;
 
  263      Guard = std::unique_lock<typename Config::mutex_type>(*M);
 
  264    Config::onDelete(Copy.Map->Data, Copy.Unwrap()); 
 
  265    Copy.Map->Map.erase(Copy); 
 
 
  270           "Invalid RAUW on key of ValueMap<>");
 
  272    ValueMapCallbackVH Copy(*
this);
 
  273    typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
 
  274    std::unique_lock<typename Config::mutex_type> Guard;
 
  276      Guard = std::unique_lock<typename Config::mutex_type>(*M);
 
  280    Config::onRAUW(Copy.Map->Data, Copy.Unwrap(), typed_new_key);
 
  281    if (Config::FollowRAUW) {
 
  285      if (
I != Copy.Map->Map.end()) {
 
  286        ValueT 
Target(std::move(
I->second));
 
  287        Copy.Map->Map.erase(
I); 
 
  288        Copy.Map->insert(std::make_pair(typed_new_key, std::move(
Target)));
 
 
 
  294template <
typename KeyT, 
typename ValueT, 
typename Config>
 
  317    return LHS == 
RHS.getValPtr();
 
 
 
  321template <
typename DenseMapT, 
typename KeyT, 
bool IsConst>
 
  323  using BaseT = std::conditional_t<IsConst, 
typename DenseMapT::const_iterator,
 
  324                                   typename DenseMapT::iterator>;
 
  325  using ValueT = 
typename DenseMapT::mapped_type;
 
  331  using value_type = std::pair<KeyT, typename DenseMapT::mapped_type>;
 
  340  template <
bool C = IsConst, 
typename = std::enable_if_t<C>>
 
  345  BaseT 
base()
 const { 
return I; }
 
  349    std::conditional_t<IsConst, const ValueT &, ValueT &> 
second;
 
  353    operator std::pair<KeyT, ValueT>()
 const {
 
 
 
  359    ValueTypeProxy Result = {I->first.Unwrap(), I->second};
 
 
 
  379template <
typename DenseMapT, 
typename KeyT>
 
  382template <
typename DenseMapT, 
typename KeyT>
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
 
This file defines DenseMapInfo traits for DenseMap.
 
This file defines the DenseMap class.
 
CallbackVH(const CallbackVH &)=default
 
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
 
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
 
Target - Wrapper for Target specific information.
 
Value * getValPtr() const
 
void allUsesReplacedWith(Value *new_key) override
Callback for Value RAUW.
 
void deleted() override
Callback for Value destruction.
 
ValueTypeProxy operator*() const
 
ValueMapIteratorImpl operator++(int)
 
bool operator!=(const ValueMapIteratorImpl &RHS) const
 
std::pair< KeyT, typename MapT::mapped_type > value_type
 
bool operator==(const ValueMapIteratorImpl &RHS) const
 
ValueTypeProxy operator->() const
 
std::forward_iterator_tag iterator_category
 
ValueMapIteratorImpl(const ValueMapIteratorImpl< DenseMapT, KeyT, false > &Other)
 
ValueMapIteratorImpl(BaseT I)
 
ValueMapIteratorImpl & operator++()
 
ValueMapIteratorImpl()=default
 
std::ptrdiff_t difference_type
 
void insert(InputIt I, InputIt E)
insert - Range insertion of pairs.
 
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
 
WeakTrackingVH mapped_type
 
bool isPointerIntoBucketsArray(const void *Ptr) const
isPointerIntoBucketsArray - Return true if the specified pointer points somewhere into the ValueMap's...
 
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
 
std::pair< const Value *, WeakTrackingVH > value_type
 
std::optional< MDMapT > & getMDMap()
 
ValueMap & operator=(ValueMap &&)=delete
 
value_type & FindAndConstruct(const KeyT &Key)
 
ValueMapIteratorImpl< MapT, const Value *, true > const_iterator
 
iterator find(const KeyT &Val)
 
std::optional< Metadata * > getMappedMD(const Metadata *MD) const
Get the mapped metadata, if it's in the map.
 
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
 
const void * getPointerIntoBucketsArray() const
getPointerIntoBucketsArray() - Return an opaque pointer into the buckets array.
 
std::pair< iterator, bool > insert(std::pair< KeyT, ValueT > &&KV)
 
const_iterator find(const KeyT &Val) const
 
ValueMap(unsigned NumInitBuckets=64)
 
ValueT & operator[](const KeyT &Key)
 
void reserve(size_t Size)
Grow the map so that it has at least Size buckets. Does not shrink.
 
ValueMap(const ExtraData &Data, unsigned NumInitBuckets=64)
 
const_iterator end() const
 
const_iterator begin() const
 
ValueMapIteratorImpl< MapT, const Value *, false > iterator
 
bool erase(const KeyT &Val)
 
ValueMap & operator=(const ValueMap &)=delete
 
ValueMap(const ValueMap &)=delete
 
ValueMap(ValueMap &&)=delete
 
LLVM Value Representation.
 
This is an optimization pass for GlobalISel generic memory operations.
 
ValueMapIteratorImpl< DenseMapT, KeyT, false > ValueMapIterator
 
auto cast_or_null(const Y &Val)
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
ValueMapIteratorImpl< DenseMapT, KeyT, true > ValueMapConstIterator
 
static unsigned getHashValue(const KeyT &Val)
 
static VH getTombstoneKey()
 
ValueMapCallbackVH< KeyT, ValueT, Config > VH
 
static bool isEqual(const KeyT &LHS, const VH &RHS)
 
static unsigned getHashValue(const VH &Val)
 
static bool isEqual(const VH &LHS, const VH &RHS)
 
An information struct used to provide DenseMap with the various necessary components for a given valu...
 
This class defines the default behavior for configurable aspects of ValueMap<>.
 
static mutex_type * getMutex(const ExtraDataT &)
Returns a mutex that should be acquired around any changes to the map.
 
static void onDelete(const ExtraDataT &, KeyT)
 
static void onRAUW(const ExtraDataT &, KeyT, KeyT)
 
ValueTypeProxy * operator->()
 
std::conditional_t< IsConst, const ValueT &, ValueT & > second