diff options
Diffstat (limited to 'llvm/lib/TextAPI')
| -rw-r--r-- | llvm/lib/TextAPI/ELF/ELFStub.cpp | 28 | ||||
| -rw-r--r-- | llvm/lib/TextAPI/ELF/TBEHandler.cpp | 160 | ||||
| -rw-r--r-- | llvm/lib/TextAPI/MachO/InterfaceFile.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/TextAPI/MachO/Platform.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/TextAPI/MachO/Target.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/TextAPI/MachO/TextStub.cpp | 27 | ||||
| -rw-r--r-- | llvm/lib/TextAPI/MachO/TextStubCommon.cpp | 3 |
7 files changed, 21 insertions, 204 deletions
diff --git a/llvm/lib/TextAPI/ELF/ELFStub.cpp b/llvm/lib/TextAPI/ELF/ELFStub.cpp deleted file mode 100644 index f8463497093b..000000000000 --- a/llvm/lib/TextAPI/ELF/ELFStub.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===- ELFStub.cpp --------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===-----------------------------------------------------------------------===/ - -#include "llvm/TextAPI/ELF/ELFStub.h" - -using namespace llvm; -using namespace llvm::elfabi; - -ELFStub::ELFStub(ELFStub const &Stub) { - TbeVersion = Stub.TbeVersion; - Arch = Stub.Arch; - SoName = Stub.SoName; - NeededLibs = Stub.NeededLibs; - Symbols = Stub.Symbols; -} - -ELFStub::ELFStub(ELFStub &&Stub) { - TbeVersion = std::move(Stub.TbeVersion); - Arch = std::move(Stub.Arch); - SoName = std::move(Stub.SoName); - NeededLibs = std::move(Stub.NeededLibs); - Symbols = std::move(Stub.Symbols); -} diff --git a/llvm/lib/TextAPI/ELF/TBEHandler.cpp b/llvm/lib/TextAPI/ELF/TBEHandler.cpp deleted file mode 100644 index cb597d8896e8..000000000000 --- a/llvm/lib/TextAPI/ELF/TBEHandler.cpp +++ /dev/null @@ -1,160 +0,0 @@ -//===- TBEHandler.cpp -----------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===-----------------------------------------------------------------------===/ - -#include "llvm/TextAPI/ELF/TBEHandler.h" -#include "llvm/ADT/StringSwitch.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/YAMLTraits.h" -#include "llvm/TextAPI/ELF/ELFStub.h" - -using namespace llvm; -using namespace llvm::elfabi; - -LLVM_YAML_STRONG_TYPEDEF(ELFArch, ELFArchMapper) - -namespace llvm { -namespace yaml { - -/// YAML traits for ELFSymbolType. -template <> struct ScalarEnumerationTraits<ELFSymbolType> { - static void enumeration(IO &IO, ELFSymbolType &SymbolType) { - IO.enumCase(SymbolType, "NoType", ELFSymbolType::NoType); - IO.enumCase(SymbolType, "Func", ELFSymbolType::Func); - IO.enumCase(SymbolType, "Object", ELFSymbolType::Object); - IO.enumCase(SymbolType, "TLS", ELFSymbolType::TLS); - IO.enumCase(SymbolType, "Unknown", ELFSymbolType::Unknown); - // Treat other symbol types as noise, and map to Unknown. - if (!IO.outputting() && IO.matchEnumFallback()) - SymbolType = ELFSymbolType::Unknown; - } -}; - -/// YAML traits for ELFArch. -template <> struct ScalarTraits<ELFArchMapper> { - static void output(const ELFArchMapper &Value, void *, - llvm::raw_ostream &Out) { - // Map from integer to architecture string. - switch (Value) { - case (ELFArch)ELF::EM_X86_64: - Out << "x86_64"; - break; - case (ELFArch)ELF::EM_AARCH64: - Out << "AArch64"; - break; - case (ELFArch)ELF::EM_NONE: - default: - Out << "Unknown"; - } - } - - static StringRef input(StringRef Scalar, void *, ELFArchMapper &Value) { - // Map from architecture string to integer. - Value = StringSwitch<ELFArch>(Scalar) - .Case("x86_64", ELF::EM_X86_64) - .Case("AArch64", ELF::EM_AARCH64) - .Case("Unknown", ELF::EM_NONE) - .Default(ELF::EM_NONE); - - // Returning empty StringRef indicates successful parse. - return StringRef(); - } - - // Don't place quotation marks around architecture value. - static QuotingType mustQuote(StringRef) { return QuotingType::None; } -}; - -/// YAML traits for TbeVersion. -template <> struct ScalarTraits<VersionTuple> { - static void output(const VersionTuple &Value, void *, - llvm::raw_ostream &Out) { - Out << Value.getAsString(); - } - - static StringRef input(StringRef Scalar, void *, VersionTuple &Value) { - if (Value.tryParse(Scalar)) - return StringRef("Can't parse version: invalid version format."); - - if (Value > TBEVersionCurrent) - return StringRef("Unsupported TBE version."); - - // Returning empty StringRef indicates successful parse. - return StringRef(); - } - - // Don't place quotation marks around version value. - static QuotingType mustQuote(StringRef) { return QuotingType::None; } -}; - -/// YAML traits for ELFSymbol. -template <> struct MappingTraits<ELFSymbol> { - static void mapping(IO &IO, ELFSymbol &Symbol) { - IO.mapRequired("Type", Symbol.Type); - // The need for symbol size depends on the symbol type. - if (Symbol.Type == ELFSymbolType::NoType) { - IO.mapOptional("Size", Symbol.Size, (uint64_t)0); - } else if (Symbol.Type == ELFSymbolType::Func) { - Symbol.Size = 0; - } else { - IO.mapRequired("Size", Symbol.Size); - } - IO.mapOptional("Undefined", Symbol.Undefined, false); - IO.mapOptional("Weak", Symbol.Weak, false); - IO.mapOptional("Warning", Symbol.Warning); - } - - // Compacts symbol information into a single line. - static const bool flow = true; -}; - -/// YAML traits for set of ELFSymbols. -template <> struct CustomMappingTraits<std::set<ELFSymbol>> { - static void inputOne(IO &IO, StringRef Key, std::set<ELFSymbol> &Set) { - ELFSymbol Sym(Key.str()); - IO.mapRequired(Key.str().c_str(), Sym); - Set.insert(Sym); - } - - static void output(IO &IO, std::set<ELFSymbol> &Set) { - for (auto &Sym : Set) - IO.mapRequired(Sym.Name.c_str(), const_cast<ELFSymbol &>(Sym)); - } -}; - -/// YAML traits for ELFStub objects. -template <> struct MappingTraits<ELFStub> { - static void mapping(IO &IO, ELFStub &Stub) { - if (!IO.mapTag("!tapi-tbe", true)) - IO.setError("Not a .tbe YAML file."); - IO.mapRequired("TbeVersion", Stub.TbeVersion); - IO.mapOptional("SoName", Stub.SoName); - IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch); - IO.mapOptional("NeededLibs", Stub.NeededLibs); - IO.mapRequired("Symbols", Stub.Symbols); - } -}; - -} // end namespace yaml -} // end namespace llvm - -Expected<std::unique_ptr<ELFStub>> elfabi::readTBEFromBuffer(StringRef Buf) { - yaml::Input YamlIn(Buf); - std::unique_ptr<ELFStub> Stub(new ELFStub()); - YamlIn >> *Stub; - if (std::error_code Err = YamlIn.error()) - return createStringError(Err, "YAML failed reading as TBE"); - - return std::move(Stub); -} - -Error elfabi::writeTBEToOutputStream(raw_ostream &OS, const ELFStub &Stub) { - yaml::Output YamlOut(OS, NULL, /*WrapColumn =*/0); - - YamlOut << const_cast<ELFStub &>(Stub); - return Error::success(); -} diff --git a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp index 64d2c3e865ab..cfc1c584d496 100644 --- a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp +++ b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp @@ -69,7 +69,6 @@ void InterfaceFile::addParentUmbrella(const Target &Target_, StringRef Parent) { } ParentUmbrellas.emplace(Iter, Target_, std::string(Parent)); - return; } void InterfaceFile::addUUID(const Target &Target_, StringRef UUID) { @@ -83,7 +82,6 @@ void InterfaceFile::addUUID(const Target &Target_, StringRef UUID) { } UUIDs.emplace(Iter, Target_, std::string(UUID)); - return; } void InterfaceFile::addUUID(const Target &Target, uint8_t UUID[16]) { diff --git a/llvm/lib/TextAPI/MachO/Platform.cpp b/llvm/lib/TextAPI/MachO/Platform.cpp index 588ec9a4d83b..f454c1cb6b16 100644 --- a/llvm/lib/TextAPI/MachO/Platform.cpp +++ b/llvm/lib/TextAPI/MachO/Platform.cpp @@ -49,7 +49,7 @@ PlatformKind mapToPlatformKind(const Triple &Target) { case Triple::WatchOS: return Target.isSimulatorEnvironment() ? PlatformKind::watchOSSimulator : PlatformKind::watchOS; - // TODO: add bridgeOS once in llvm::Triple + // TODO: add bridgeOS & driverKit once in llvm::Triple } llvm_unreachable("Unknown Target Triple"); } @@ -83,6 +83,8 @@ StringRef getPlatformName(PlatformKind Platform) { return "tvOS Simulator"; case PlatformKind::watchOSSimulator: return "watchOS Simulator"; + case PlatformKind::driverKit: + return "DriverKit"; } llvm_unreachable("Unknown llvm.MachO.PlatformKind enum"); } diff --git a/llvm/lib/TextAPI/MachO/Target.cpp b/llvm/lib/TextAPI/MachO/Target.cpp index aee8ef421425..6f8d9bb4e19a 100644 --- a/llvm/lib/TextAPI/MachO/Target.cpp +++ b/llvm/lib/TextAPI/MachO/Target.cpp @@ -33,6 +33,7 @@ Expected<Target> Target::create(StringRef TargetValue) { .Case("ios-simulator", PlatformKind::iOSSimulator) .Case("tvos-simulator", PlatformKind::tvOSSimulator) .Case("watchos-simulator", PlatformKind::watchOSSimulator) + .Case("driverkit", PlatformKind::driverKit) .Default(PlatformKind::unknown); if (Platform == PlatformKind::unknown) { diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp index 141f897fb564..1d6352b2e126 100644 --- a/llvm/lib/TextAPI/MachO/TextStub.cpp +++ b/llvm/lib/TextAPI/MachO/TextStub.cpp @@ -407,6 +407,9 @@ template <> struct ScalarTraits<Target> { case PlatformKind::watchOSSimulator: OS << "watchos-simulator"; break; + case PlatformKind::driverKit: + OS << "driverkit"; + break; } } @@ -518,13 +521,12 @@ template <> struct MappingTraits<const InterfaceFile *> { break; } } - llvm::sort(Section.Symbols.begin(), Section.Symbols.end()); - llvm::sort(Section.Classes.begin(), Section.Classes.end()); - llvm::sort(Section.ClassEHs.begin(), Section.ClassEHs.end()); - llvm::sort(Section.IVars.begin(), Section.IVars.end()); - llvm::sort(Section.WeakDefSymbols.begin(), - Section.WeakDefSymbols.end()); - llvm::sort(Section.TLVSymbols.begin(), Section.TLVSymbols.end()); + llvm::sort(Section.Symbols); + llvm::sort(Section.Classes); + llvm::sort(Section.ClassEHs); + llvm::sort(Section.IVars); + llvm::sort(Section.WeakDefSymbols); + llvm::sort(Section.TLVSymbols); Exports.emplace_back(std::move(Section)); } @@ -576,12 +578,11 @@ template <> struct MappingTraits<const InterfaceFile *> { break; } } - llvm::sort(Section.Symbols.begin(), Section.Symbols.end()); - llvm::sort(Section.Classes.begin(), Section.Classes.end()); - llvm::sort(Section.ClassEHs.begin(), Section.ClassEHs.end()); - llvm::sort(Section.IVars.begin(), Section.IVars.end()); - llvm::sort(Section.WeakRefSymbols.begin(), - Section.WeakRefSymbols.end()); + llvm::sort(Section.Symbols); + llvm::sort(Section.Classes); + llvm::sort(Section.ClassEHs); + llvm::sort(Section.IVars); + llvm::sort(Section.WeakRefSymbols); Undefineds.emplace_back(std::move(Section)); } } diff --git a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp index 4a82df6beac1..0d3614b0a24c 100644 --- a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp +++ b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp @@ -84,6 +84,9 @@ void ScalarTraits<PlatformSet>::output(const PlatformSet &Values, void *IO, case PlatformKind::macCatalyst: OS << "iosmac"; break; + case PlatformKind::driverKit: + OS << "driverkit"; + break; } } |
