Skip to content

Commit 64051a6

Browse files
committed
Add LLVM target support for visionOS
rdar://125113602
1 parent 2988910 commit 64051a6

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

include/llvm/ADT/Triple.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class Triple {
180180
ELFIAMCU,
181181
TvOS, // Apple tvOS
182182
WatchOS, // Apple watchOS
183+
XROS, // Apple XROS
183184
Mesa3D,
184185
Contiki,
185186
AMDPAL, // AMD PAL Runtime
@@ -472,9 +473,12 @@ class Triple {
472473
return getSubArch() == Triple::ARMSubArch_v7k;
473474
}
474475

475-
/// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
476+
/// Is this an Apple XROS triple.
477+
bool isXROS() const { return getOS() == Triple::XROS; }
478+
479+
/// isOSDarwin - Is this a "Darwin" OS (OS X, iOS, watchOS, or XROS).
476480
bool isOSDarwin() const {
477-
return isMacOSX() || isiOS() || isWatchOS();
481+
return isMacOSX() || isiOS() || isWatchOS() || isXROS();
478482
}
479483

480484
bool isSimulatorEnvironment() const {

lib/LLVMSupport/Support/Triple.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
202202
case ELFIAMCU: return "elfiamcu";
203203
case TvOS: return "tvos";
204204
case WatchOS: return "watchos";
205+
case XROS: return "xros";
205206
case Mesa3D: return "mesa3d";
206207
case Contiki: return "contiki";
207208
case AMDPAL: return "amdpal";
@@ -501,6 +502,8 @@ static Triple::OSType parseOS(StringRef OSName) {
501502
.StartsWith("elfiamcu", Triple::ELFIAMCU)
502503
.StartsWith("tvos", Triple::TvOS)
503504
.StartsWith("watchos", Triple::WatchOS)
505+
.StartsWith("xros", Triple::XROS)
506+
.StartsWith("visionos", Triple::XROS)
504507
.StartsWith("mesa3d", Triple::Mesa3D)
505508
.StartsWith("contiki", Triple::Contiki)
506509
.StartsWith("amdpal", Triple::AMDPAL)
@@ -1051,6 +1054,8 @@ void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
10511054
OSName = OSName.substr(OSTypeName.size());
10521055
else if (getOS() == MacOSX)
10531056
OSName.consume_front("macos");
1057+
else if (OSName.startswith("visionos"))
1058+
OSName.consume_front("visionos");
10541059

10551060
parseVersionFromName(OSName, Major, Minor, Micro);
10561061
}
@@ -1092,6 +1097,8 @@ bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
10921097
Minor = 4;
10931098
Micro = 0;
10941099
break;
1100+
case XROS:
1101+
llvm_unreachable("OSX version isn't relevant for xrOS");
10951102
}
10961103
return true;
10971104
}
@@ -1119,6 +1126,12 @@ void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
11191126
break;
11201127
case WatchOS:
11211128
llvm_unreachable("conflicting triple info");
1129+
case XROS: {
1130+
// xrOS 1 is aligned with iOS 17.
1131+
getOSVersion(Major, Minor, Micro);
1132+
Major += 16;
1133+
break;
1134+
}
11221135
}
11231136
}
11241137

@@ -1143,6 +1156,8 @@ void Triple::getWatchOSVersion(unsigned &Major, unsigned &Minor,
11431156
break;
11441157
case IOS:
11451158
llvm_unreachable("conflicting triple info");
1159+
case XROS:
1160+
llvm_unreachable("watchOS version isn't relevant for xrOS");
11461161
}
11471162
}
11481163

0 commit comments

Comments
 (0)