[llvm] r364981 - Add support for the 'macCatalyst' MachO platform
Alex Lorenz via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 16:47:12 PDT 2019
Author: arphaman
Date: Tue Jul 2 16:47:11 2019
New Revision: 364981
URL: http://llvm.org/viewvc/llvm-project?rev=364981&view=rev
Log:
Add support for the 'macCatalyst' MachO platform
Mac Catalyst is a new MachO platform in macOS Catalina.
It always uses the build_version MachO load command.
Differential Revision: https://reviews.llvm.org/D64107
Added:
llvm/trunk/test/CodeGen/X86/macCatalyst.ll
llvm/trunk/test/MC/MachO/build-version-maccatalyst.s
llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml
Modified:
llvm/trunk/include/llvm/BinaryFormat/MachO.h
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s
Modified: llvm/trunk/include/llvm/BinaryFormat/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/MachO.h?rev=364981&r1=364980&r2=364981&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/MachO.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/MachO.h Tue Jul 2 16:47:11 2019
@@ -487,6 +487,7 @@ enum PlatformType {
PLATFORM_TVOS = 3,
PLATFORM_WATCHOS = 4,
PLATFORM_BRIDGEOS = 5,
+ PLATFORM_MACCATALYST = 6,
PLATFORM_IOSSIMULATOR = 7,
PLATFORM_TVOSSIMULATOR = 8,
PLATFORM_WATCHOSSIMULATOR = 9
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=364981&r1=364980&r2=364981&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Tue Jul 2 16:47:11 2019
@@ -608,6 +608,7 @@ public:
case MachO::PLATFORM_TVOS: return "tvos";
case MachO::PLATFORM_WATCHOS: return "watchos";
case MachO::PLATFORM_BRIDGEOS: return "bridgeos";
+ case MachO::PLATFORM_MACCATALYST: return "maccatalyst";
case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator";
case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator";
case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator";
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=364981&r1=364980&r2=364981&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue Jul 2 16:47:11 2019
@@ -541,6 +541,7 @@ static const char *getPlatformName(MachO
case MachO::PLATFORM_TVOS: return "tvos";
case MachO::PLATFORM_WATCHOS: return "watchos";
case MachO::PLATFORM_BRIDGEOS: return "bridgeos";
+ case MachO::PLATFORM_MACCATALYST: return "maccatalyst";
case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator";
case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator";
case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator";
Modified: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp?rev=364981&r1=364980&r2=364981&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp Tue Jul 2 16:47:11 2019
@@ -1148,6 +1148,7 @@ static Triple::OSType getOSTypeFromPlatf
case MachO::PLATFORM_TVOS: return Triple::TvOS;
case MachO::PLATFORM_WATCHOS: return Triple::WatchOS;
case MachO::PLATFORM_BRIDGEOS: /* silence warning */ break;
+ case MachO::PLATFORM_MACCATALYST: return Triple::IOS;
case MachO::PLATFORM_IOSSIMULATOR: /* silence warning */ break;
case MachO::PLATFORM_TVOSSIMULATOR: /* silence warning */ break;
case MachO::PLATFORM_WATCHOSSIMULATOR: /* silence warning */ break;
@@ -1168,6 +1169,7 @@ bool DarwinAsmParser::parseBuildVersion(
.Case("ios", MachO::PLATFORM_IOS)
.Case("tvos", MachO::PLATFORM_TVOS)
.Case("watchos", MachO::PLATFORM_WATCHOS)
+ .Case("maccatalyst", MachO::PLATFORM_MACCATALYST)
.Default(0);
if (Platform == 0)
return Error(PlatformLoc, "unknown platform name");
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=364981&r1=364980&r2=364981&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Tue Jul 2 16:47:11 2019
@@ -1077,6 +1077,15 @@ void MCStreamer::EmitVersionForTarget(co
unsigned Major;
unsigned Minor;
unsigned Update;
+ if (Target.isMacCatalystEnvironment()) {
+ // Mac Catalyst always uses the build version load command.
+ Target.getiOSVersion(Major, Minor, Update);
+ assert(Major && "A non-zero major version is expected");
+ EmitBuildVersion(MachO::PLATFORM_MACCATALYST, Major, Minor, Update,
+ SDKVersion);
+ return;
+ }
+
MCVersionMinType VersionType;
if (Target.isWatchOS()) {
VersionType = MCVM_WatchOSVersionMin;
Added: llvm/trunk/test/CodeGen/X86/macCatalyst.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/macCatalyst.ll?rev=364981&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/macCatalyst.ll (added)
+++ llvm/trunk/test/CodeGen/X86/macCatalyst.ll Tue Jul 2 16:47:11 2019
@@ -0,0 +1,3 @@
+; RUN: llc %s -o - | FileCheck %s
+target triple="x86_64-apple-ios13.0-maccatalyst"
+; CHECK: .build_version maccatalyst, 13, 0
Added: llvm/trunk/test/MC/MachO/build-version-maccatalyst.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/build-version-maccatalyst.s?rev=364981&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/build-version-maccatalyst.s (added)
+++ llvm/trunk/test/MC/MachO/build-version-maccatalyst.s Tue Jul 2 16:47:11 2019
@@ -0,0 +1,4 @@
+// RUN: llvm-mc -triple x86_64-apple-ios %s | FileCheck %s
+
+.build_version maccatalyst,13,0
+// CHECK: .build_version maccatalyst, 13, 0
Modified: llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s?rev=364981&r1=364980&r2=364981&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s (original)
+++ llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s Tue Jul 2 16:47:11 2019
@@ -1,6 +1,7 @@
// RUN: llvm-mc -triple x86_64-apple-macosx10.10.0 %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s
// RUN: llvm-mc -triple x86_64-apple-ios8.0.0 %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s --check-prefix=CHECK-IOS
// RUN: llvm-mc -triple x86_64-apple-darwin %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s --check-prefix=CHECK-DARWIN
+// RUN: llvm-mc -triple x86_64-apple-ios13.0-maccatalyst %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s --check-prefix=CHECK-MACCATALYST
// Test version-min load command should be inferred from triple and should always be generated on Darwin
// CHECK: Load command
@@ -33,3 +34,10 @@
// CHECK-BRIDGEOS-NEXT: sdk n/a
// CHECK-BRIDGEOS-NEXT: minos 2.0
// CHECK-BRIDGEOS-NEXT: ntools 0
+
+// CHECK-MACCATALYST: cmd LC_BUILD_VERSION
+// CHECK-MACCATALYST-NEXT: cmdsize 24
+// CHECK-MACCATALYST-NEXT: platform maccatalyst
+// CHECK-MACCATALYST-NEXT: sdk n/a
+// CHECK-MACCATALYST-NEXT: minos 13.0
+// CHECK-MACCATALYST-NEXT: ntools 0
Added: llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml?rev=364981&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml (added)
+++ llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml Tue Jul 2 16:47:11 2019
@@ -0,0 +1,54 @@
+# RUN: yaml2obj %s | llvm-objdump -macho -private-headers - | FileCheck %s
+
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x00000003
+ filetype: 0x00000004
+ ncmds: 2
+ sizeofcmds: 192
+ flags: 0x00000000
+ reserved: 0
+LoadCommands:
+ - cmd: LC_SEGMENT_64
+ cmdsize: 152
+ segname: __TEXT
+ vmaddr: 4294967296
+ vmsize: 8192
+ fileoff: 0
+ filesize: 3099
+ maxprot: 7
+ initprot: 5
+ nsects: 1
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000100001160
+ size: 3099
+ offset: 0x00001160
+ align: 4
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ - cmd: LC_BUILD_VERSION
+ cmdsize: 32
+ platform: 6
+ minos: 0x000D0000
+ sdk: 0x00090000
+ ntools: 1
+ Tools:
+ - tool: 1
+ version: 0x00000000
+...
+
+CHECK: Load command 1
+CHECK-NEXT: cmd LC_BUILD_VERSION
+CHECK-NEXT: cmdsize 32
+CHECK-NEXT: platform maccatalyst
+CHECK-NEXT: sdk 9.0
+CHECK-NEXT: minos 13.0
More information about the llvm-commits
mailing list