[llvm] Triple: Add BridgeOS to isOSDarwin (PR #145636)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 24 22:18:22 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
@llvm/pr-subscribers-llvm-ir
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/145636.diff
5 Files Affected:
- (modified) llvm/include/llvm/TargetParser/Triple.h (+7-2)
- (modified) llvm/lib/IR/RuntimeLibcalls.cpp (+1-4)
- (modified) llvm/lib/MC/MCStreamer.cpp (+6)
- (modified) llvm/test/CodeGen/AArch64/exp10-libcall-names.ll (+3-13)
- (modified) llvm/unittests/TargetParser/TripleTest.cpp (+38)
``````````diff
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index d6fa4537ee3b4..22602e3a1c61f 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, XROS, bridgeOS, or
+ /// DriverKit).
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..ac8013d5ddbdf 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1458,6 +1458,9 @@ static VersionTuple getMachoBuildVersionSupportedOS(const Triple &Target) {
case Triple::XROS:
// XROS always uses the build version load command.
return VersionTuple();
+ case Triple::BridgeOS:
+ // Who knows?
+ return VersionTuple();
default:
break;
}
@@ -1487,6 +1490,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 +1525,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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/145636
More information about the llvm-commits
mailing list