LLVM  14.0.0git
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
llvm::StringMapImpl Class Reference

StringMapImpl - This is the base class of StringMap that is shared among all of its instantiations. More...

#include "llvm/ADT/StringMap.h"

Inherited by llvm::StringMap< ValueTy, AllocatorTy >, llvm::StringMap< bool >, llvm::StringMap< bool, llvm::BumpPtrAllocatorImpl & >, llvm::StringMap< Comdat >, llvm::StringMap< const llvm::DIE * >, llvm::StringMap< const PassInfo * >, llvm::StringMap< const RegisterBank * >, llvm::StringMap< const TargetRegisterClass * >, llvm::StringMap< const uint32_t * >, llvm::StringMap< ContextSamplesTy >, llvm::StringMap< CountAndDurationType >, llvm::StringMap< DwarfStringPoolEntry, BumpPtrAllocator >, llvm::StringMap< GlobalResolution >, llvm::StringMap< GlobalValue::LinkageTypes >, llvm::StringMap< HashData, BumpPtrAllocator & >, llvm::StringMap< int >, llvm::StringMap< IRData >, llvm::StringMap< llvm::AssertingVH< llvm::Constant >, llvm::BumpPtrAllocatorImpl >, llvm::StringMap< llvm::cl::Option * >, llvm::StringMap< llvm::Constant * >, llvm::StringMap< llvm::DwarfStringPoolEntry, llvm::BumpPtrAllocatorImpl & >, llvm::StringMap< llvm::GCStrategy * >, llvm::StringMap< llvm::MCAsmMacro >, llvm::StringMap< llvm::MCSectionMachO * >, llvm::StringMap< llvm::MDString, llvm::BumpPtrAllocatorImpl >, llvm::StringMap< llvm::NumericVariable * >, llvm::StringMap< llvm::orc::ExecutorAddr >, llvm::StringMap< llvm::Register >, llvm::StringMap< llvm::sampleprof::ProfiledCallGraphNode >, llvm::StringMap< llvm::SDNode * >, llvm::StringMap< llvm::SmallDenseMap >, llvm::StringMap< llvm::SmallVector >, llvm::StringMap< llvm::SmallVector< llvm::Annotations::Range, 1 > >, llvm::StringMap< llvm::SmallVector< size_t, 1 > >, llvm::StringMap< llvm::StringRef >, llvm::StringMap< llvm::StructType * >, llvm::StringMap< llvm::Type * >, llvm::StringMap< llvm::VRegInfo * >, llvm::StringMap< MachineMemOperand::Flags >, llvm::StringMap< MCSymbol *, BumpPtrAllocator & >, llvm::StringMap< NameAndAttributes >, llvm::StringMap< NamedMDNode * >, llvm::StringMap< NoneType, MallocAllocator >, llvm::StringMap< NumericVariableMatch >, llvm::StringMap< ProbeFactorMap >, llvm::StringMap< RefCountType >, llvm::StringMap< SectionList >, llvm::StringMap< SectionParserFunction >, llvm::StringMap< State >, llvm::StringMap< std::pair< llvm::Type *, llvm::SMLoc > >, llvm::StringMap< std::pair< StubKey, llvm::JITSymbolFlags > >, llvm::StringMap< std::pair< uint64_t, ModuleHash > >, llvm::StringMap< std::string >, llvm::StringMap< std::unique_ptr< const llvm::ExternalSymbolPseudoSourceValue > >, llvm::StringMap< std::unique_ptr< InlineGraphNode > >, llvm::StringMap< std::unique_ptr< llvm::AArch64Subtarget > >, llvm::StringMap< std::unique_ptr< llvm::ARMSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::ConstantDataSequential > >, llvm::StringMap< std::unique_ptr< llvm::GCNSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::HexagonSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::M68kSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::MipsSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::orc::DebugObjectSection > >, llvm::StringMap< std::unique_ptr< llvm::PPCSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::R600Subtarget > >, llvm::StringMap< std::unique_ptr< llvm::RISCVSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::SetTheory::Expander > >, llvm::StringMap< std::unique_ptr< llvm::SetTheory::Operator > >, llvm::StringMap< std::unique_ptr< llvm::SparcSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::SystemZSubtarget > >, llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >, llvm::StringMap< std::unique_ptr< llvm::WebAssemblySubtarget > >, llvm::StringMap< std::unique_ptr< llvm::X86Subtarget > >, llvm::StringMap< std::vector< llvm::Record * > >, llvm::StringMap< std::vector< llvm::support::detail::packed_endian_specific_integral > >, llvm::StringMap< std::vector< std::string > >, llvm::StringMap< std::weak_ptr< DWOFile > >, llvm::StringMap< StringMap< Matcher > >, llvm::StringMap< SymbolTableEntry >, llvm::StringMap< uint32_t >, llvm::StringMap< uint64_t >, llvm::StringMap< uint8_t >, llvm::StringMap< unsigned >, llvm::StringMap< unsigned, llvm::BumpPtrAllocatorImpl >, and llvm::StringMap< Value * >.

Collaboration diagram for llvm::StringMapImpl:
Collaboration graph
[legend]

Public Member Functions

unsigned getNumBuckets () const
 
unsigned getNumItems () const
 
bool empty () const
 
unsigned size () const
 
void swap (StringMapImpl &Other)
 

Static Public Member Functions

static StringMapEntryBasegetTombstoneVal ()
 

Static Public Attributes

static constexpr uintptr_t TombstoneIntVal
 

Protected Member Functions

 StringMapImpl (unsigned itemSize)
 
 StringMapImpl (StringMapImpl &&RHS)
 
 StringMapImpl (unsigned InitSize, unsigned ItemSize)
 
unsigned RehashTable (unsigned BucketNo=0)
 RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hashtable-size. More...
 
unsigned LookupBucketFor (StringRef Key)
 LookupBucketFor - Look up the bucket that the specified string should end up in. More...
 
int FindKey (StringRef Key) const
 FindKey - Look up the bucket that contains the specified key. More...
 
void RemoveKey (StringMapEntryBase *V)
 RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it. More...
 
StringMapEntryBaseRemoveKey (StringRef Key)
 RemoveKey - Remove the StringMapEntry for the specified key from the table, returning it. More...
 
void init (unsigned Size)
 Allocate the table with the specified number of buckets and otherwise setup the map as empty. More...
 

Protected Attributes

StringMapEntryBase ** TheTable = nullptr
 
unsigned NumBuckets = 0
 
unsigned NumItems = 0
 
unsigned NumTombstones = 0
 
unsigned ItemSize
 

Detailed Description

StringMapImpl - This is the base class of StringMap that is shared among all of its instantiations.

Definition at line 30 of file StringMap.h.

Constructor & Destructor Documentation

◆ StringMapImpl() [1/3]

llvm::StringMapImpl::StringMapImpl ( unsigned  itemSize)
inlineexplicitprotected

Definition at line 42 of file StringMap.h.

◆ StringMapImpl() [2/3]

llvm::StringMapImpl::StringMapImpl ( StringMapImpl &&  RHS)
inlineprotected

Definition at line 43 of file StringMap.h.

◆ StringMapImpl() [3/3]

StringMapImpl::StringMapImpl ( unsigned  InitSize,
unsigned  ItemSize 
)
protected

Member Function Documentation

◆ empty()

bool llvm::StringMapImpl::empty ( ) const
inline

◆ FindKey()

int StringMapImpl::FindKey ( StringRef  Key) const
protected

FindKey - Look up the bucket that contains the specified key.

If it exists in the map, return the bucket number of the key. Otherwise return -1. This does not modify the map.

Definition at line 132 of file StringMap.cpp.

References llvm::djbHash(), llvm::StringMapEntryBase::getKeyLength(), getTombstoneVal(), ItemSize, LLVM_LIKELY, NumBuckets, and TheTable.

Referenced by llvm::StringSet< AllocatorTy >::contains(), llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::find(), and RemoveKey().

◆ getNumBuckets()

unsigned llvm::StringMapImpl::getNumBuckets ( ) const
inline

Definition at line 89 of file StringMap.h.

References NumBuckets.

◆ getNumItems()

unsigned llvm::StringMapImpl::getNumItems ( ) const
inline

Definition at line 90 of file StringMap.h.

References NumItems.

◆ getTombstoneVal()

static StringMapEntryBase* llvm::StringMapImpl::getTombstoneVal ( )
inlinestatic

◆ init()

void StringMapImpl::init ( unsigned  Size)
protected

Allocate the table with the specified number of buckets and otherwise setup the map as empty.

Definition at line 50 of file StringMap.cpp.

References assert(), NumBuckets, NumItems, NumTombstones, llvm::safe_calloc(), and TheTable.

Referenced by LookupBucketFor(), llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::StringMap(), and StringMapImpl().

◆ LookupBucketFor()

unsigned StringMapImpl::LookupBucketFor ( StringRef  Name)
protected

LookupBucketFor - Look up the bucket that the specified string should end up in.

If it already exists as a key in the map, the Item pointer for the specified bucket will be non-null. Otherwise, it will be null. In either case, the FullHashValue field of the bucket will be set to the hash value of the string.

Definition at line 74 of file StringMap.cpp.

References llvm::djbHash(), llvm::StringMapEntryBase::getKeyLength(), getTombstoneVal(), init(), ItemSize, LLVM_LIKELY, NumBuckets, and TheTable.

Referenced by llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::insert(), and llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::try_emplace().

◆ RehashTable()

unsigned StringMapImpl::RehashTable ( unsigned  BucketNo = 0)
protected

RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hashtable-size.

Definition at line 200 of file StringMap.cpp.

References E, getTombstoneVal(), I, LLVM_UNLIKELY, NumBuckets, NumItems, NumTombstones, llvm::safe_calloc(), and TheTable.

Referenced by llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::insert(), and llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::try_emplace().

◆ RemoveKey() [1/2]

void StringMapImpl::RemoveKey ( StringMapEntryBase V)
protected

RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.

This aborts if the value isn't in the table.

Definition at line 175 of file StringMap.cpp.

References assert(), llvm::StringMapEntryBase::getKeyLength(), ItemSize, and llvm::NVPTX::PTXLdStInstCode::V2.

Referenced by llvm::StringMap< std::unique_ptr< llvm::vfs::detail::InMemoryNode > >::remove().

◆ RemoveKey() [2/2]

StringMapEntryBase * StringMapImpl::RemoveKey ( StringRef  Key)
protected

RemoveKey - Remove the StringMapEntry for the specified key from the table, returning it.

If the key is not in the table, this returns null.

Definition at line 184 of file StringMap.cpp.

References assert(), FindKey(), getTombstoneVal(), NumBuckets, NumItems, NumTombstones, and TheTable.

◆ size()

unsigned llvm::StringMapImpl::size ( ) const
inline

◆ swap()

void llvm::StringMapImpl::swap ( StringMapImpl Other)
inline

Member Data Documentation

◆ ItemSize

unsigned llvm::StringMapImpl::ItemSize
protected

Definition at line 39 of file StringMap.h.

Referenced by FindKey(), LookupBucketFor(), RemoveKey(), and StringMapImpl().

◆ NumBuckets

unsigned llvm::StringMapImpl::NumBuckets = 0
protected

◆ NumItems

unsigned llvm::StringMapImpl::NumItems = 0
protected

◆ NumTombstones

unsigned llvm::StringMapImpl::NumTombstones = 0
protected

◆ TheTable

StringMapEntryBase** llvm::StringMapImpl::TheTable = nullptr
protected

◆ TombstoneIntVal

constexpr uintptr_t llvm::StringMapImpl::TombstoneIntVal
staticconstexpr
Initial value:
=
static_cast<uintptr_t>(-1)
<< PointerLikeTypeTraits<StringMapEntryBase *>::NumLowBitsAvailable

Definition at line 81 of file StringMap.h.

Referenced by getTombstoneVal().


The documentation for this class was generated from the following files: