[llvm] b991b21 - Triple: Add BridgeOS to isOSDarwin (#145636)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 04:06:55 PDT 2025
Author: Matt Arsenault
Date: 2025-06-25T20:06:51+09:00
New Revision: b991b21874ed3250ebf02606e0845c2eba4b1949
URL: https://github.com/llvm/llvm-project/commit/b991b21874ed3250ebf02606e0845c2eba4b1949
DIFF: https://github.com/llvm/llvm-project/commit/b991b21874ed3250ebf02606e0845c2eba4b1949.diff
LOG: Triple: Add BridgeOS to isOSDarwin (#145636)
This fixes a TODO and avoids a special case. Also required
hacking up a few cases to avoid asserting in codegen; it's not
confidence inspiring that there is only one codegen test using
a bridgeos triple and its specifically for the exp10 libcall
names.
This also changes the behavior, losing an extra leading _ in the
emitted name matching the other apple outputs. I have no idea if
this is right or not. IMO it's someone from apple's problem to fix
it and add appropriate test coverage, or we can rip all references
to BridgeOS out from upstream.
Added:
Modified:
llvm/include/llvm/TargetParser/Triple.h
llvm/lib/IR/RuntimeLibcalls.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/test/CodeGen/AArch64/exp10-libcall-names.ll
llvm/unittests/TargetParser/TripleTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index d6fa4537ee3b4..1865be6e95dea 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -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; }
@@ -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 {
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 702e0a51357f5..e9cb970f804ca 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -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)) {
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 5f1fd57802c7b..6cd6b4abdd327 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -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;
@@ -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;
}
@@ -1520,6 +1521,7 @@ void MCStreamer::emitVersionForTarget(
Version = Target.getDriverKitVersion();
break;
case Triple::XROS:
+ case Triple::BridgeOS:
Version = Target.getOSVersion();
break;
default:
diff --git a/llvm/test/CodeGen/AArch64/exp10-libcall-names.ll b/llvm/test/CodeGen/AArch64/exp10-libcall-names.ll
index 6e603b7064f8f..50358e5f15879 100644
--- a/llvm/test/CodeGen/AArch64/exp10-libcall-names.ll
+++ b/llvm/test/CodeGen/AArch64/exp10-libcall-names.ll
@@ -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
@@ -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
}
@@ -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
}
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 0f6d07657c931..4d547011c1568 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -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;
More information about the llvm-commits
mailing list