LLVM  10.0.0svn
InterfaceFile.cpp
Go to the documentation of this file.
1 //===- InterfaceFile.cpp --------------------------------------------------===//
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 //
9 // Implements the Interface File.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include <iomanip>
15 #include <sstream>
16 
17 namespace llvm {
18 namespace MachO {
19 namespace detail {
20 template <typename C>
21 typename C::iterator addEntry(C &Container, StringRef InstallName) {
22  auto I = partition_point(Container, [=](const InterfaceFileRef &O) {
23  return O.getInstallName() < InstallName;
24  });
25  if (I != Container.end() && I->getInstallName() == InstallName)
26  return I;
27 
28  return Container.emplace(I, InstallName);
29 }
30 } // end namespace detail.
31 
33  ArchitectureSet Architectures) {
34  auto Client = detail::addEntry(AllowableClients, Name);
35  Client->addArchitectures(Architectures);
36 }
37 
39  ArchitectureSet Architectures) {
40  auto Lib = detail::addEntry(ReexportedLibraries, InstallName);
41  Lib->addArchitectures(Architectures);
42 }
43 
45  auto I = partition_point(UUIDs,
46  [=](const std::pair<Architecture, std::string> &O) {
47  return O.first < Arch;
48  });
49 
50  if (I != UUIDs.end() && Arch == I->first) {
51  I->second = UUID;
52  return;
53  }
54 
55  UUIDs.emplace(I, Arch, UUID);
56  return;
57 }
58 
59 void InterfaceFile::addUUID(Architecture Arch, uint8_t UUID[16]) {
60  std::stringstream Stream;
61  for (unsigned i = 0; i < 16; ++i) {
62  if (i == 4 || i == 6 || i == 8 || i == 10)
63  Stream << '-';
64  Stream << std::setfill('0') << std::setw(2) << std::uppercase << std::hex
65  << static_cast<int>(UUID[i]);
66  }
67  addUUID(Arch, Stream.str());
68 }
69 
71  ArchitectureSet Archs, SymbolFlags Flags) {
72  Name = copyString(Name);
73  auto result = Symbols.try_emplace(SymbolsMapKey{Kind, Name}, nullptr);
74  if (result.second)
75  result.first->second = new (Allocator) Symbol{Kind, Name, Archs, Flags};
76  else
77  result.first->second->addArchitectures(Archs);
78 }
79 
80 } // end namespace MachO.
81 } // end namespace llvm.
uint64_t CallInst * C
void addAllowableClient(StringRef Name, ArchitectureSet Architectures)
Add an allowable client.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void addSymbol(SymbolKind Kind, StringRef Name, ArchitectureSet Architectures, SymbolFlags Flags=SymbolFlags::None)
Add a symbol to the symbols list or extend an existing one.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Reference to an interface file.
Definition: InterfaceFile.h:86
void addUUID(Architecture Arch, StringRef UUID)
Add an architecture/UUID pair.
C::iterator addEntry(C &Container, StringRef InstallName)
void addReexportedLibrary(StringRef InstallName, ArchitectureSet Architectures)
Add a re-exported library.
StringRef getInstallName() const
Definition: InterfaceFile.h:95
SymbolFlags
Symbol flags.
Definition: Symbol.h:24
auto partition_point(R &&Range, Predicate P) -> decltype(adl_begin(Range))
Binary search for the first iterator in a range where a predicate is false.
Definition: STLExtras.h:1314
std::pair< llvm::MachO::Architecture, std::string > UUID
Basic Register Allocator
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition: Architecture.h:23
#define I(x, y, z)
Definition: MD5.cpp:58
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48