-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[llvm] Introduce XROS platform #77707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Accepts but otherwise ignore visionOS/XROS target triples.
@llvm/pr-subscribers-llvm-binary-utilities @llvm/pr-subscribers-mc Author: Cyndy Ishida (cyndyishida) ChangesAccepts but otherwise ignores visionOS/XROS target triples as Darwin based platform. https://developer.apple.com/documentation/visionos Full diff: https://github.com/llvm/llvm-project/pull/77707.diff 6 Files Affected:
diff --git a/llvm/include/llvm/BinaryFormat/MachO.def b/llvm/include/llvm/BinaryFormat/MachO.def
index df527b4a8ab7c3..4124c723ec021f 100644
--- a/llvm/include/llvm/BinaryFormat/MachO.def
+++ b/llvm/include/llvm/BinaryFormat/MachO.def
@@ -133,6 +133,8 @@ PLATFORM(IOSSIMULATOR, 7, iossimulator, iossimulator, ios-simulator, ios-simulat
PLATFORM(TVOSSIMULATOR, 8, tvossimulator, tvossimulator, tvos-simulator, tvos-simulator, tvOS Simulator)
PLATFORM(WATCHOSSIMULATOR, 9, watchossimulator, watchossimulator, watchos-simulator, watchos-simulator, watchOS Simulator)
PLATFORM(DRIVERKIT, 10, driverkit, driverkit, driverkit, driverkit, DriverKit)
+PLATFORM(XROS, 11, xros, xros, xros, xros, xrOS)
+PLATFORM(XROS_SIMULATOR, 12, xrsimulator, xrsimulator, xrsimulator, xros-simulator, xrOS Simulator)
#endif
#undef HANDLE_LOAD_COMMAND
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 95014a546f7245..34ff7a8ccc43d7 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -214,6 +214,8 @@ class Triple {
TvOS, // Apple tvOS
WatchOS, // Apple watchOS
DriverKit, // Apple DriverKit
+ XROS, // Apple XROS
+
Mesa3D,
AMDPAL, // AMD PAL Runtime
HermitCore, // HermitCore Unikernel/Multikernel
@@ -514,14 +516,17 @@ class Triple {
return getSubArch() == Triple::ARMSubArch_v7k;
}
+ /// Is this an Apple XROS triple.
+ bool isXROS() const { return getOS() == Triple::XROS; }
+
/// Is this an Apple DriverKit triple.
bool isDriverKit() const { return getOS() == Triple::DriverKit; }
bool isOSzOS() const { return getOS() == Triple::ZOS; }
- /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, or DriverKit).
+ /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, XROS, or DriverKit).
bool isOSDarwin() const {
- return isMacOSX() || isiOS() || isWatchOS() || isDriverKit();
+ return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS();
}
bool isSimulatorEnvironment() const {
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index edea5a56bec3d3..3cd44e7195be62 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -1147,6 +1147,7 @@ static Triple::OSType getOSTypeFromPlatform(MachO::PlatformType Type) {
case MachO::PLATFORM_IOS: return Triple::IOS;
case MachO::PLATFORM_TVOS: return Triple::TvOS;
case MachO::PLATFORM_WATCHOS: return Triple::WatchOS;
+ case MachO::PLATFORM_XROS: return Triple::XROS;
case MachO::PLATFORM_BRIDGEOS: /* silence warning */ break;
case MachO::PLATFORM_DRIVERKIT:
return Triple::DriverKit;
@@ -1154,6 +1155,7 @@ static Triple::OSType getOSTypeFromPlatform(MachO::PlatformType Type) {
case MachO::PLATFORM_IOSSIMULATOR: /* silence warning */ break;
case MachO::PLATFORM_TVOSSIMULATOR: /* silence warning */ break;
case MachO::PLATFORM_WATCHOSSIMULATOR: /* silence warning */ break;
+ case MachO::PLATFORM_XROS_SIMULATOR: /* silence warning */ break;
}
llvm_unreachable("Invalid mach-o platform type");
}
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index b9971c25af71f3..cc696745c7dd5e 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -273,6 +273,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case ZOS: return "zos";
case ShaderModel: return "shadermodel";
case LiteOS: return "liteos";
+ case XROS: return "xros";
}
llvm_unreachable("Invalid OSType");
@@ -634,6 +635,8 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("tvos", Triple::TvOS)
.StartsWith("watchos", Triple::WatchOS)
.StartsWith("driverkit", Triple::DriverKit)
+ .StartsWith("xros", Triple::XROS)
+ .StartsWith("visionos", Triple::XROS)
.StartsWith("mesa3d", Triple::Mesa3D)
.StartsWith("amdpal", Triple::AMDPAL)
.StartsWith("hermit", Triple::HermitCore)
@@ -1224,6 +1227,8 @@ VersionTuple Triple::getOSVersion() const {
OSName = OSName.substr(OSTypeName.size());
else if (getOS() == MacOSX)
OSName.consume_front("macos");
+ else if (OSName.starts_with("visionos"))
+ OSName.consume_front("visionos");
return parseVersionFromName(OSName);
}
@@ -1289,6 +1294,11 @@ VersionTuple Triple::getiOSVersion() const {
return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
return Version;
}
+ case XROS: {
+ // xrOS 1 is aligned with iOS 17.
+ VersionTuple Version = getOSVersion();
+ return Version.withMajorReplaced(Version.getMajor() + 16);
+ }
case WatchOS:
llvm_unreachable("conflicting triple info");
case DriverKit:
diff --git a/llvm/lib/TextAPI/Platform.cpp b/llvm/lib/TextAPI/Platform.cpp
index ed041af40aa5b7..e891594300c2e4 100644
--- a/llvm/lib/TextAPI/Platform.cpp
+++ b/llvm/lib/TextAPI/Platform.cpp
@@ -106,6 +106,10 @@ std::string getOSAndEnvironmentName(PlatformType Platform,
return "watchos" + Version + "-simulator";
case PLATFORM_DRIVERKIT:
return "driverkit" + Version;
+ case PLATFORM_XROS:
+ return "xros" + Version;
+ case PLATFORM_XROS_SIMULATOR:
+ return "xros" + Version + "-simulator";
}
llvm_unreachable("Unknown llvm::MachO::PlatformType enum");
}
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index d3bde2986ea2cd..1b0e6c456c046e 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1746,6 +1746,42 @@ TEST(TripleTest, EndianArchVariants) {
EXPECT_EQ(Triple::dxil, T.getLittleEndianArchVariant().getArch());
}
+TEST(TripleTest, XROS) {
+ Triple T;
+ VersionTuple Version;
+
+ T = Triple("arm64-apple-xros");
+ EXPECT_TRUE(T.isXROS());
+ EXPECT_TRUE(T.isOSDarwin());
+ EXPECT_FALSE(T.isiOS());
+ EXPECT_FALSE(T.isMacOSX());
+ EXPECT_FALSE(T.isSimulatorEnvironment());
+ EXPECT_EQ(T.getOSName(), "xros");
+ Version = T.getOSVersion();
+ EXPECT_EQ(VersionTuple(0), Version);
+
+ T = Triple("arm64-apple-visionos1.2");
+ EXPECT_TRUE(T.isXROS());
+ EXPECT_TRUE(T.isOSDarwin());
+ EXPECT_FALSE(T.isiOS());
+ EXPECT_FALSE(T.isMacOSX());
+ EXPECT_FALSE(T.isSimulatorEnvironment());
+ EXPECT_EQ(T.getOSName(), "visionos1.2");
+ Version = T.getOSVersion();
+ EXPECT_EQ(VersionTuple(1, 2), Version);
+
+ T = Triple("arm64-apple-xros1-simulator");
+ EXPECT_TRUE(T.isXROS());
+ EXPECT_TRUE(T.isOSDarwin());
+ EXPECT_FALSE(T.isiOS());
+ EXPECT_FALSE(T.isMacOSX());
+ EXPECT_TRUE(T.isSimulatorEnvironment());
+ Version = T.getOSVersion();
+ EXPECT_EQ(VersionTuple(1), Version);
+ Version = T.getiOSVersion();
+ EXPECT_EQ(VersionTuple(17), Version);
+}
+
TEST(TripleTest, getOSVersion) {
Triple T;
VersionTuple Version;
|
You can test this locally with the following command:git-clang-format --diff 4a3fb9ce27dda17e97341f28005a28836c909cfc 64395216ba1e2dce28c3f580a0c7357d36caaad5 -- llvm/include/llvm/TargetParser/Triple.h llvm/lib/TargetParser/Triple.cpp llvm/lib/TextAPI/Platform.cpp llvm/unittests/TargetParser/TripleTest.cpp View the diff from clang-format here.diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 052336c8a3..189d835d9b 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -193,7 +193,7 @@ public:
IOS,
KFreeBSD,
Linux,
- Lv2, // PS3
+ Lv2, // PS3
MacOSX,
NetBSD,
OpenBSD,
@@ -203,18 +203,18 @@ public:
ZOS,
Haiku,
RTEMS,
- NaCl, // Native Client
+ NaCl, // Native Client
AIX,
- CUDA, // NVIDIA CUDA
- NVCL, // NVIDIA OpenCL
- AMDHSA, // AMD HSA Runtime
+ CUDA, // NVIDIA CUDA
+ NVCL, // NVIDIA OpenCL
+ AMDHSA, // AMD HSA Runtime
PS4,
PS5,
ELFIAMCU,
- TvOS, // Apple tvOS
- WatchOS, // Apple watchOS
- DriverKit, // Apple DriverKit
- XROS, // Apple XROS
+ TvOS, // Apple tvOS
+ WatchOS, // Apple watchOS
+ DriverKit, // Apple DriverKit
+ XROS, // Apple XROS
Mesa3D,
AMDPAL, // AMD PAL Runtime
HermitCore, // HermitCore Unikernel/Multikernel
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 40079c1dcd..b9b60d6a40 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -273,7 +273,8 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case ZOS: return "zos";
case ShaderModel: return "shadermodel";
case LiteOS: return "liteos";
- case XROS: return "xros";
+ case XROS:
+ return "xros";
}
llvm_unreachable("Invalid OSType");
@@ -606,47 +607,47 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
static Triple::OSType parseOS(StringRef OSName) {
return StringSwitch<Triple::OSType>(OSName)
- .StartsWith("darwin", Triple::Darwin)
- .StartsWith("dragonfly", Triple::DragonFly)
- .StartsWith("freebsd", Triple::FreeBSD)
- .StartsWith("fuchsia", Triple::Fuchsia)
- .StartsWith("ios", Triple::IOS)
- .StartsWith("kfreebsd", Triple::KFreeBSD)
- .StartsWith("linux", Triple::Linux)
- .StartsWith("lv2", Triple::Lv2)
- .StartsWith("macos", Triple::MacOSX)
- .StartsWith("netbsd", Triple::NetBSD)
- .StartsWith("openbsd", Triple::OpenBSD)
- .StartsWith("solaris", Triple::Solaris)
- .StartsWith("uefi", Triple::UEFI)
- .StartsWith("win32", Triple::Win32)
- .StartsWith("windows", Triple::Win32)
- .StartsWith("zos", Triple::ZOS)
- .StartsWith("haiku", Triple::Haiku)
- .StartsWith("rtems", Triple::RTEMS)
- .StartsWith("nacl", Triple::NaCl)
- .StartsWith("aix", Triple::AIX)
- .StartsWith("cuda", Triple::CUDA)
- .StartsWith("nvcl", Triple::NVCL)
- .StartsWith("amdhsa", Triple::AMDHSA)
- .StartsWith("ps4", Triple::PS4)
- .StartsWith("ps5", Triple::PS5)
- .StartsWith("elfiamcu", Triple::ELFIAMCU)
- .StartsWith("tvos", Triple::TvOS)
- .StartsWith("watchos", Triple::WatchOS)
- .StartsWith("driverkit", Triple::DriverKit)
- .StartsWith("xros", Triple::XROS)
- .StartsWith("visionos", Triple::XROS)
- .StartsWith("mesa3d", Triple::Mesa3D)
- .StartsWith("amdpal", Triple::AMDPAL)
- .StartsWith("hermit", Triple::HermitCore)
- .StartsWith("hurd", Triple::Hurd)
- .StartsWith("wasi", Triple::WASI)
- .StartsWith("emscripten", Triple::Emscripten)
- .StartsWith("shadermodel", Triple::ShaderModel)
- .StartsWith("liteos", Triple::LiteOS)
- .StartsWith("serenity", Triple::Serenity)
- .Default(Triple::UnknownOS);
+ .StartsWith("darwin", Triple::Darwin)
+ .StartsWith("dragonfly", Triple::DragonFly)
+ .StartsWith("freebsd", Triple::FreeBSD)
+ .StartsWith("fuchsia", Triple::Fuchsia)
+ .StartsWith("ios", Triple::IOS)
+ .StartsWith("kfreebsd", Triple::KFreeBSD)
+ .StartsWith("linux", Triple::Linux)
+ .StartsWith("lv2", Triple::Lv2)
+ .StartsWith("macos", Triple::MacOSX)
+ .StartsWith("netbsd", Triple::NetBSD)
+ .StartsWith("openbsd", Triple::OpenBSD)
+ .StartsWith("solaris", Triple::Solaris)
+ .StartsWith("uefi", Triple::UEFI)
+ .StartsWith("win32", Triple::Win32)
+ .StartsWith("windows", Triple::Win32)
+ .StartsWith("zos", Triple::ZOS)
+ .StartsWith("haiku", Triple::Haiku)
+ .StartsWith("rtems", Triple::RTEMS)
+ .StartsWith("nacl", Triple::NaCl)
+ .StartsWith("aix", Triple::AIX)
+ .StartsWith("cuda", Triple::CUDA)
+ .StartsWith("nvcl", Triple::NVCL)
+ .StartsWith("amdhsa", Triple::AMDHSA)
+ .StartsWith("ps4", Triple::PS4)
+ .StartsWith("ps5", Triple::PS5)
+ .StartsWith("elfiamcu", Triple::ELFIAMCU)
+ .StartsWith("tvos", Triple::TvOS)
+ .StartsWith("watchos", Triple::WatchOS)
+ .StartsWith("driverkit", Triple::DriverKit)
+ .StartsWith("xros", Triple::XROS)
+ .StartsWith("visionos", Triple::XROS)
+ .StartsWith("mesa3d", Triple::Mesa3D)
+ .StartsWith("amdpal", Triple::AMDPAL)
+ .StartsWith("hermit", Triple::HermitCore)
+ .StartsWith("hurd", Triple::Hurd)
+ .StartsWith("wasi", Triple::WASI)
+ .StartsWith("emscripten", Triple::Emscripten)
+ .StartsWith("shadermodel", Triple::ShaderModel)
+ .StartsWith("liteos", Triple::LiteOS)
+ .StartsWith("serenity", Triple::Serenity)
+ .Default(Triple::UnknownOS);
}
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The formatting issues are the result of the surrounding code not being compliant. Personally don't think it's worth the churn but even if it were that's something to be fixed in a separate PR.
Correct. I feel like the right thing is to add |
Since this change also adds MC support, I think this commit should also add the MC build version test for visionOS/xrOS. Alternatively, the MC support and test could be added in a separate commit. |
Makes sense, will move that change out to a follow up patch. |
These changes seem necessary to build (and otherwise seem like they're required at least for consistency): rust-lang@a6cf499 Turns out I misunderstood. This PR is missing many changes that are necessary to build LLVM with xrOS support. I'm not sure what milestone these changes represent, but in any case I don't think these are directly actionable. |
Correct. I suspect #78373 covers the rest of the changes necessary, at least under the |
That's important to know, thank you. Yes, Rust maintains a fork with some targeted changes and thus is lagging behind |
Accepts but otherwise ignores visionOS/XROS target triples as Darwin based platform. https://developer.apple.com/documentation/visionos
Accepts but otherwise ignores visionOS/XROS target triples as Darwin based platform. https://developer.apple.com/documentation/visionos
Accepts but otherwise ignores visionOS/XROS target triples as Darwin based platform. https://developer.apple.com/documentation/visionos (cherry picked from commit 7d3466b)
Accepts but otherwise ignores visionOS/XROS target triples as Darwin based platform. https://developer.apple.com/documentation/visionos (cherry picked from commit 7d3466b)
Accepts but otherwise ignores visionOS/XROS target triples as Darwin based platform.
https://developer.apple.com/documentation/visionos