From 25e7b20da03c83228cc8019e441f569375ee2a18 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 5 Mar 2020 10:04:32 -0800 Subject: [PATCH] [TextAPI] Teach TextAPI about arm64e Reviewers: ributzka, cishida Subscribers: kristof.beyls, dexonsmith, dcoughlin, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75688 --- include/llvm/TextAPI/MachO/Architecture.def | 1 + unittests/TextAPI/TextStubV3Tests.cpp | 25 +++++++++++++++++++++ unittests/TextAPI/TextStubV4Tests.cpp | 22 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/include/llvm/TextAPI/MachO/Architecture.def b/include/llvm/TextAPI/MachO/Architecture.def index 4c695fe18ee..be31382147b 100644 --- a/include/llvm/TextAPI/MachO/Architecture.def +++ b/include/llvm/TextAPI/MachO/Architecture.def @@ -36,3 +36,4 @@ ARCHINFO(armv7em, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7EM) /// ARM64 architectures sorted by cpu sub type id. /// ARCHINFO(arm64, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64_ALL) +ARCHINFO(arm64e, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64E) diff --git a/unittests/TextAPI/TextStubV3Tests.cpp b/unittests/TextAPI/TextStubV3Tests.cpp index e67fd38eceb..6e7c087296e 100644 --- a/unittests/TextAPI/TextStubV3Tests.cpp +++ b/unittests/TextAPI/TextStubV3Tests.cpp @@ -408,6 +408,31 @@ TEST(TBDv3, Platform_tvOSSim) { stripWhitespace(Buffer.c_str())); } +TEST(TBDv3, Arch_arm64e) { + static const char TBDv3ArchArm64e[] = "--- !tapi-tbd-v3\n" + "archs: [ arm64, arm64e ]\n" + "platform: ios\n" + "install-name: Test.dylib\n" + "...\n"; + + auto Result = + TextAPIReader::get(MemoryBufferRef(TBDv3ArchArm64e, "Test.tbd")); + EXPECT_TRUE(!!Result); + auto File = std::move(Result.get()); + auto Platform = PlatformKind::iOS; + auto Archs = AK_arm64 | AK_arm64e; + EXPECT_EQ(FileType::TBD_V3, File->getFileType()); + EXPECT_EQ(File->getPlatforms().size(), 1U); + EXPECT_EQ(Platform, *File->getPlatforms().begin()); + EXPECT_EQ(Archs, File->getArchitectures()); + + SmallString<4096> Buffer; + raw_svector_ostream OS(Buffer); + auto WriteResult = TextAPIWriter::writeToStream(OS, *File); + EXPECT_TRUE(!WriteResult); + EXPECT_EQ(stripWhitespace(TBDv3ArchArm64e), stripWhitespace(Buffer.c_str())); +} + TEST(TBDv3, Swift_1_0) { static const char TBDv3Swift1[] = "--- !tapi-tbd-v3\n" "archs: [ arm64 ]\n" diff --git a/unittests/TextAPI/TextStubV4Tests.cpp b/unittests/TextAPI/TextStubV4Tests.cpp index 07af8f20dea..cecc6d19f50 100644 --- a/unittests/TextAPI/TextStubV4Tests.cpp +++ b/unittests/TextAPI/TextStubV4Tests.cpp @@ -375,6 +375,28 @@ TEST(TBDv4, Target_arm_bridgeOS) { stripWhitespace(Buffer.c_str())); } +TEST(TBDv4, Target_arm_iOS) { + static const char tbdv4_arm64e[] = "--- !tapi-tbd\n" + "tbd-version: 4\n" + "targets: [ arm64e-ios ]\n" + "install-name: Test.dylib\n" + "...\n"; + + auto Result = TextAPIReader::get(MemoryBufferRef(tbdv4_arm64e, "Test.tbd")); + EXPECT_TRUE(!!Result); + auto File = std::move(Result.get()); + EXPECT_EQ(FileType::TBD_V4, File->getFileType()); + EXPECT_EQ(File->getPlatforms().size(), 1U); + EXPECT_EQ(PlatformKind::iOS, *File->getPlatforms().begin()); + EXPECT_EQ(ArchitectureSet(AK_arm64e), File->getArchitectures()); + + SmallString<4096> Buffer; + raw_svector_ostream OS(Buffer); + auto WriteResult = TextAPIWriter::writeToStream(OS, *File); + EXPECT_TRUE(!WriteResult); + EXPECT_EQ(stripWhitespace(tbdv4_arm64e), stripWhitespace(Buffer.c_str())); +} + TEST(TBDv4, Target_x86_macos) { static const char tbd_x86_macos[] = "--- !tapi-tbd\n" "tbd-version: 4\n"