Skip to content

[6.0] Add LLVM target support for visionOS #184

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

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class Triple {
ELFIAMCU,
TvOS, // Apple tvOS
WatchOS, // Apple watchOS
XROS, // Apple XROS
Mesa3D,
Contiki,
AMDPAL, // AMD PAL Runtime
Expand Down Expand Up @@ -472,9 +473,12 @@ class Triple {
return getSubArch() == Triple::ARMSubArch_v7k;
}

/// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
/// Is this an Apple XROS triple.
bool isXROS() const { return getOS() == Triple::XROS; }

/// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, watchOS, or XROS).
bool isOSDarwin() const {
return isMacOSX() || isiOS() || isWatchOS();
return isMacOSX() || isiOS() || isWatchOS() || isXROS();
}

bool isSimulatorEnvironment() const {
Expand Down
15 changes: 15 additions & 0 deletions lib/LLVMSupport/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case ELFIAMCU: return "elfiamcu";
case TvOS: return "tvos";
case WatchOS: return "watchos";
case XROS: return "xros";
case Mesa3D: return "mesa3d";
case Contiki: return "contiki";
case AMDPAL: return "amdpal";
Expand Down Expand Up @@ -501,6 +502,8 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("elfiamcu", Triple::ELFIAMCU)
.StartsWith("tvos", Triple::TvOS)
.StartsWith("watchos", Triple::WatchOS)
.StartsWith("xros", Triple::XROS)
.StartsWith("visionos", Triple::XROS)
.StartsWith("mesa3d", Triple::Mesa3D)
.StartsWith("contiki", Triple::Contiki)
.StartsWith("amdpal", Triple::AMDPAL)
Expand Down Expand Up @@ -1051,6 +1054,8 @@ void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
OSName = OSName.substr(OSTypeName.size());
else if (getOS() == MacOSX)
OSName.consume_front("macos");
else if (OSName.startswith("visionos"))
OSName.consume_front("visionos");

parseVersionFromName(OSName, Major, Minor, Micro);
}
Expand Down Expand Up @@ -1092,6 +1097,8 @@ bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
Minor = 4;
Micro = 0;
break;
case XROS:
llvm_unreachable("OSX version isn't relevant for xrOS");
}
return true;
}
Expand Down Expand Up @@ -1119,6 +1126,12 @@ void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
break;
case WatchOS:
llvm_unreachable("conflicting triple info");
case XROS: {
// xrOS 1 is aligned with iOS 17.
getOSVersion(Major, Minor, Micro);
Major += 16;
break;
}
}
}

Expand All @@ -1143,6 +1156,8 @@ void Triple::getWatchOSVersion(unsigned &Major, unsigned &Minor,
break;
case IOS:
llvm_unreachable("conflicting triple info");
case XROS:
llvm_unreachable("watchOS version isn't relevant for xrOS");
}
}

Expand Down