Skip to content

Triple: Add BridgeOS to isOSDarwin #145636

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 2 commits into from
Jun 25, 2025
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
9 changes: 7 additions & 2 deletions llvm/include/llvm/TargetParser/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ class Triple {
/// Is this an Apple XROS triple.
bool isXROS() const { return getOS() == Triple::XROS; }

/// Is this an Apple BridgeOS triple.
bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }

/// Is this an Apple DriverKit triple.
bool isDriverKit() const { return getOS() == Triple::DriverKit; }

Expand All @@ -591,9 +594,11 @@ class Triple {
return (getVendor() == Triple::Apple) && isOSBinFormatMachO();
}

/// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, XROS, or DriverKit).
/// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
/// bridgeOS).
bool isOSDarwin() const {
return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS();
return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
isBridgeOS();
}

bool isSimulatorEnvironment() const {
Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,13 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
case Triple::TvOS:
case Triple::WatchOS:
case Triple::XROS:
case Triple::BridgeOS:
setLibcallName(RTLIB::EXP10_F32, "__exp10f");
setLibcallName(RTLIB::EXP10_F64, "__exp10");
break;
default:
break;
}
} else if (TT.getOS() == Triple::BridgeOS) {
// TODO: BridgeOS should be included in isOSDarwin.
setLibcallName(RTLIB::EXP10_F32, "__exp10f");
setLibcallName(RTLIB::EXP10_F64, "__exp10");
}

if (hasSinCos(TT)) {
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/MC/MCStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,10 +1453,9 @@ static VersionTuple getMachoBuildVersionSupportedOS(const Triple &Target) {
case Triple::WatchOS:
return VersionTuple(5);
case Triple::DriverKit:
// DriverKit always uses the build version load command.
return VersionTuple();
case Triple::BridgeOS:
case Triple::XROS:
// XROS always uses the build version load command.
// DriverKit/BridgeOS/XROS always use the build version load command.
return VersionTuple();
default:
break;
Expand Down Expand Up @@ -1487,6 +1486,8 @@ getMachoBuildVersionPlatformType(const Triple &Target) {
case Triple::XROS:
return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
: MachO::PLATFORM_XROS;
case Triple::BridgeOS:
return MachO::PLATFORM_BRIDGEOS;
default:
break;
}
Expand Down Expand Up @@ -1520,6 +1521,7 @@ void MCStreamer::emitVersionForTarget(
Version = Target.getDriverKitVersion();
break;
case Triple::XROS:
case Triple::BridgeOS:
Version = Target.getOSVersion();
break;
default:
Expand Down
16 changes: 3 additions & 13 deletions llvm/test/CodeGen/AArch64/exp10-libcall-names.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
; RUN: llc -mtriple=arm64-apple-driverkit < %s | FileCheck -check-prefix=APPLE %s
; RUN: llc -mtriple=arm64-apple-driverkit1.0 < %s | FileCheck -check-prefix=APPLE %s
; RUN: llc -mtriple=arm64-apple-driverkit24.0 < %s | FileCheck -check-prefix=APPLE %s
; RUN: llc -mtriple=arm64-apple-bridgeos < %s | FileCheck -check-prefix=BRIDGEOS %s
; RUN: llc -mtriple=arm64-apple-bridgeos1.0 < %s | FileCheck -check-prefix=BRIDGEOS %s
; RUN: llc -mtriple=arm64-apple-bridgeos9.0 < %s | FileCheck -check-prefix=BRIDGEOS %s
; RUN: llc -mtriple=arm64-apple-bridgeos < %s | FileCheck -check-prefix=APPLE %s
; RUN: llc -mtriple=arm64-apple-bridgeos1.0 < %s | FileCheck -check-prefix=APPLE %s
; RUN: llc -mtriple=arm64-apple-bridgeos9.0 < %s | FileCheck -check-prefix=APPLE %s

; RUN: not llc -mtriple=aarch64-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
; RUN: not llc -mtriple=aarch64-apple-ios6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
Expand All @@ -29,11 +29,6 @@ define float @test_exp10_f32(float %x) {
; APPLE-LABEL: test_exp10_f32:
; APPLE: ; %bb.0:
; APPLE-NEXT: b ___exp10f
;
; BRIDGEOS-LABEL: test_exp10_f32:
; BRIDGEOS: // %bb.0:
; BRIDGEOS-NEXT: b __exp10f
;
%ret = call float @llvm.exp10.f32(float %x)
ret float %ret
}
Expand All @@ -46,11 +41,6 @@ define double @test_exp10_f64(double %x) {
; APPLE-LABEL: test_exp10_f64:
; APPLE: ; %bb.0:
; APPLE-NEXT: b ___exp10
;
; BRIDGEOS-LABEL: test_exp10_f64:
; BRIDGEOS: // %bb.0:
; BRIDGEOS-NEXT: b __exp10
;
%ret = call double @llvm.exp10.f64(double %x)
ret double %ret
}
38 changes: 38 additions & 0 deletions llvm/unittests/TargetParser/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,44 @@ TEST(TripleTest, XROS) {
EXPECT_EQ(VersionTuple(17), Version);
}

TEST(TripleTest, BridgeOS) {
Triple T;
VersionTuple Version;

T = Triple("arm64-apple-bridgeos");
EXPECT_TRUE(T.isBridgeOS());
EXPECT_FALSE(T.isXROS());
EXPECT_TRUE(T.isOSDarwin());
EXPECT_FALSE(T.isiOS());
EXPECT_FALSE(T.isMacOSX());
EXPECT_FALSE(T.isSimulatorEnvironment());
EXPECT_EQ(T.getOSName(), "bridgeos");
Version = T.getOSVersion();
EXPECT_EQ(VersionTuple(0), Version);

T = Triple("arm64-apple-bridgeos1.0");
EXPECT_TRUE(T.isBridgeOS());
EXPECT_FALSE(T.isXROS());
EXPECT_TRUE(T.isOSDarwin());
EXPECT_FALSE(T.isiOS());
EXPECT_FALSE(T.isMacOSX());
EXPECT_FALSE(T.isSimulatorEnvironment());
EXPECT_EQ(T.getOSName(), "bridgeos1.0");
Version = T.getOSVersion();
EXPECT_EQ(VersionTuple(1), Version);

T = Triple("arm64-apple-bridgeos9.0");
EXPECT_TRUE(T.isBridgeOS());
EXPECT_FALSE(T.isXROS());
EXPECT_TRUE(T.isOSDarwin());
EXPECT_FALSE(T.isiOS());
EXPECT_FALSE(T.isMacOSX());
EXPECT_FALSE(T.isSimulatorEnvironment());
EXPECT_EQ(T.getOSName(), "bridgeos9.0");
Version = T.getOSVersion();
EXPECT_EQ(VersionTuple(9), Version);
}

TEST(TripleTest, getOSVersion) {
Triple T;
VersionTuple Version;
Expand Down
Loading