#ifndef LLVM_IR_VALUEMAP_H
#define LLVM_IR_VALUEMAP_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Mutex.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <mutex>
#include <optional>
#include <type_traits>
#include <utility>
namespace llvm {
template<typename KeyT, typename ValueT, typename Config>
class ValueMapCallbackVH;
template<typename DenseMapT, typename KeyT>
class ValueMapIterator;
template<typename DenseMapT, typename KeyT>
class ValueMapConstIterator;
template<typename KeyT, typename MutexT = sys::Mutex>
struct ValueMapConfig { … };
template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT>>
class ValueMap {
friend class ValueMapCallbackVH<KeyT, ValueT, Config>;
using ValueMapCVH = ValueMapCallbackVH<KeyT, ValueT, Config>;
using MapT = DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>>;
using MDMapT = DenseMap<const Metadata *, TrackingMDRef>;
using ExtraData = typename Config::ExtraData;
MapT Map;
std::optional<MDMapT> MDMap;
ExtraData Data;
public:
using key_type = KeyT;
using mapped_type = ValueT;
using value_type = std::pair<KeyT, ValueT>;
using size_type = unsigned;
explicit ValueMap(unsigned NumInitBuckets = 64)
: … { … }
explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64)
: … { … }
ValueMap(const ValueMap &) = delete;
ValueMap(ValueMap &&) = delete;
ValueMap &operator=(const ValueMap &) = delete;
ValueMap &operator=(ValueMap &&) = delete;
bool hasMD() const { … }
MDMapT &MD() { … }
std::optional<MDMapT> &getMDMap() { … }
std::optional<Metadata *> getMappedMD(const Metadata *MD) const { … }
using iterator = ValueMapIterator<MapT, KeyT>;
using const_iterator = ValueMapConstIterator<MapT, KeyT>;
inline iterator begin() { … }
inline iterator end() { … }
inline const_iterator begin() const { … }
inline const_iterator end() const { … }
bool empty() const { … }
size_type size() const { … }
void reserve(size_t Size) { … }
void clear() { … }
size_type count(const KeyT &Val) const { … }
iterator find(const KeyT &Val) { … }
const_iterator find(const KeyT &Val) const { … }
ValueT lookup(const KeyT &Val) const { … }
std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) { … }
std::pair<iterator, bool> insert(std::pair<KeyT, ValueT> &&KV) { … }
template<typename InputIt>
void insert(InputIt I, InputIt E) { … }
bool erase(const KeyT &Val) { … }
void erase(iterator I) { … }
value_type& FindAndConstruct(const KeyT &Key) { … }
ValueT &operator[](const KeyT &Key) { … }
bool isPointerIntoBucketsArray(const void *Ptr) const { … }
const void *getPointerIntoBucketsArray() const { … }
private:
ValueMapCVH Wrap(KeyT key) const { … }
};
template <typename KeyT, typename ValueT, typename Config>
class ValueMapCallbackVH final : public CallbackVH { … };
DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config>>;
template <typename DenseMapT, typename KeyT> class ValueMapIterator { … };
template <typename DenseMapT, typename KeyT> class ValueMapConstIterator { … };
}
#endif