LLVM 22.0.0git
SymbolSet.cpp
Go to the documentation of this file.
1//===- lib/TextAPI/SymbolSet.cpp - TAPI Symbol Set ------------*- C++-*----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11using namespace llvm;
12using namespace llvm::MachO;
13
15 for (auto &[Key, Sym] : Symbols)
16 Sym->~Symbol();
17}
18
19Symbol *SymbolSet::addGlobalImpl(EncodeKind Kind, StringRef Name,
20 SymbolFlags Flags) {
21 Name = copyString(Name);
22 auto Result = Symbols.try_emplace(SymbolsMapKey{Kind, Name}, nullptr);
23 if (Result.second)
24 Result.first->second =
25 new (Allocator) Symbol{Kind, Name, TargetList(), Flags};
26 return Result.first->second;
27}
28
30 const Target &Targ) {
31 auto *Sym = addGlobalImpl(Kind, Name, Flags);
32 Sym->addTarget(Targ);
33 return Sym;
34}
35
37 ObjCIFSymbolKind ObjCIF) const {
38 if (auto result = Symbols.lookup({Kind, Name}))
39 return result;
40 if ((ObjCIF == ObjCIFSymbolKind::None) || (ObjCIF > ObjCIFSymbolKind::EHType))
41 return nullptr;
43 "expected single ObjCIFSymbolKind enum value");
44 // Non-complete ObjC Interfaces are represented as global symbols.
45 if (ObjCIF == ObjCIFSymbolKind::Class)
46 return Symbols.lookup(
48 if (ObjCIF == ObjCIFSymbolKind::MetaClass)
49 return Symbols.lookup(
51 return Symbols.lookup(
53}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:479
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:203
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition: DenseMap.h:245
LLVM_ABI Symbol * addGlobal(EncodeKind Kind, StringRef Name, SymbolFlags Flags, const Target &Targ)
Definition: SymbolSet.cpp:29
LLVM_ABI const Symbol * findSymbol(EncodeKind Kind, StringRef Name, ObjCIFSymbolKind ObjCIF=ObjCIFSymbolKind::None) const
Definition: SymbolSet.cpp:36
void addTarget(Target InputTarget)
Definition: Symbol.h:102
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
constexpr StringLiteral ObjC2ClassNamePrefix
Definition: Symbol.h:64
SmallVector< Target, 5 > TargetList
Definition: Symbol.h:82
ObjCIFSymbolKind
ObjC Interface symbol mappings.
Definition: Symbol.h:70
@ EHType
Is OBJC_EHTYPE* symbol.
@ Class
Is OBJC_CLASS* symbol.
@ MetaClass
Is OBJC_METACLASS* symbol.
EncodeKind
Mapping of entry types in TextStubs.
Definition: Symbol.h:56
constexpr StringLiteral ObjC2MetaClassNamePrefix
Definition: Symbol.h:65
SymbolFlags
Symbol flags.
Definition: Symbol.h:25
constexpr StringLiteral ObjC2EHTypePrefix
Definition: Symbol.h:66
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18