LLVM 20.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
14Symbol *SymbolSet::addGlobalImpl(EncodeKind Kind, StringRef Name,
15 SymbolFlags Flags) {
16 Name = copyString(Name);
17 auto Result = Symbols.try_emplace(SymbolsMapKey{Kind, Name}, nullptr);
18 if (Result.second)
19 Result.first->second =
20 new (Allocator) Symbol{Kind, Name, TargetList(), Flags};
21 return Result.first->second;
22}
23
25 const Target &Targ) {
26 auto *Sym = addGlobalImpl(Kind, Name, Flags);
27 Sym->addTarget(Targ);
28 return Sym;
29}
30
32 ObjCIFSymbolKind ObjCIF) const {
33 if (auto result = Symbols.lookup({Kind, Name}))
34 return result;
35 if ((ObjCIF == ObjCIFSymbolKind::None) || (ObjCIF > ObjCIFSymbolKind::EHType))
36 return nullptr;
38 "expected single ObjCIFSymbolKind enum value");
39 // Non-complete ObjC Interfaces are represented as global symbols.
40 if (ObjCIF == ObjCIFSymbolKind::Class)
41 return Symbols.lookup(
43 if (ObjCIF == ObjCIFSymbolKind::MetaClass)
44 return Symbols.lookup(
46 return Symbols.lookup(
48}
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:479
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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:194
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition: DenseMap.h:226
Symbol * addGlobal(EncodeKind Kind, StringRef Name, SymbolFlags Flags, const Target &Targ)
Definition: SymbolSet.cpp:24
const Symbol * findSymbol(EncodeKind Kind, StringRef Name, ObjCIFSymbolKind ObjCIF=ObjCIFSymbolKind::None) const
Definition: SymbolSet.cpp:31
void addTarget(Target InputTarget)
Definition: Symbol.h:101
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
constexpr StringLiteral ObjC2ClassNamePrefix
Definition: Symbol.h:63
SmallVector< Target, 5 > TargetList
Definition: Symbol.h:81
ObjCIFSymbolKind
ObjC Interface symbol mappings.
Definition: Symbol.h:69
@ 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:55
constexpr StringLiteral ObjC2MetaClassNamePrefix
Definition: Symbol.h:64
SymbolFlags
Symbol flags.
Definition: Symbol.h:24
constexpr StringLiteral ObjC2EHTypePrefix
Definition: Symbol.h:65
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18