[ARM] Generate 8.1-m CSINC, CSNEG and CSINV instructions.
[llvm-core.git] / lib / TextAPI / MachO / InterfaceFile.cpp
blob54ba8cc312673b08069c799d6915ead7b59fbf42
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.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/TextAPI/MachO/InterfaceFile.h"
14 #include <iomanip>
15 #include <sstream>
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;
28 return Container.emplace(I, InstallName);
30 } // end namespace detail.
32 void InterfaceFile::addAllowableClient(StringRef Name,
33 ArchitectureSet Architectures) {
34 auto Client = detail::addEntry(AllowableClients, Name);
35 Client->addArchitectures(Architectures);
38 void InterfaceFile::addReexportedLibrary(StringRef InstallName,
39 ArchitectureSet Architectures) {
40 auto Lib = detail::addEntry(ReexportedLibraries, InstallName);
41 Lib->addArchitectures(Architectures);
44 void InterfaceFile::addUUID(Architecture Arch, StringRef UUID) {
45 auto I = partition_point(UUIDs,
46 [=](const std::pair<Architecture, std::string> &O) {
47 return O.first < Arch;
48 });
50 if (I != UUIDs.end() && Arch == I->first) {
51 I->second = UUID;
52 return;
55 UUIDs.emplace(I, Arch, UUID);
56 return;
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]);
67 addUUID(Arch, Stream.str());
70 void InterfaceFile::addSymbol(SymbolKind Kind, StringRef Name,
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);
80 } // end namespace MachO.
81 } // end namespace llvm.