Skip to content

Commit ff579b3

Browse files
arsenmAnthony Tran
authored andcommitted
Triple: Add BridgeOS to isOSDarwin (llvm#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.
1 parent f8cceb0 commit ff579b3

File tree

5 files changed

+54
-22
lines changed

5 files changed

+54
-22
lines changed

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ class Triple {
581581
/// Is this an Apple XROS triple.
582582
bool isXROS() const { return getOS() == Triple::XROS; }
583583

584+
/// Is this an Apple BridgeOS triple.
585+
bool isBridgeOS() const { return getOS() == Triple::BridgeOS; }
586+
584587
/// Is this an Apple DriverKit triple.
585588
bool isDriverKit() const { return getOS() == Triple::DriverKit; }
586589

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

594-
/// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, XROS, or DriverKit).
597+
/// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or
598+
/// bridgeOS).
595599
bool isOSDarwin() const {
596-
return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS();
600+
return isMacOSX() || isiOS() || isWatchOS() || isDriverKit() || isXROS() ||
601+
isBridgeOS();
597602
}
598603

599604
bool isSimulatorEnvironment() const {

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,13 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
478478
case Triple::TvOS:
479479
case Triple::WatchOS:
480480
case Triple::XROS:
481+
case Triple::BridgeOS:
481482
setLibcallName(RTLIB::EXP10_F32, "__exp10f");
482483
setLibcallName(RTLIB::EXP10_F64, "__exp10");
483484
break;
484485
default:
485486
break;
486487
}
487-
} else if (TT.getOS() == Triple::BridgeOS) {
488-
// TODO: BridgeOS should be included in isOSDarwin.
489-
setLibcallName(RTLIB::EXP10_F32, "__exp10f");
490-
setLibcallName(RTLIB::EXP10_F64, "__exp10");
491488
}
492489

493490
if (hasSinCos(TT)) {

llvm/lib/MC/MCStreamer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,10 +1453,9 @@ static VersionTuple getMachoBuildVersionSupportedOS(const Triple &Target) {
14531453
case Triple::WatchOS:
14541454
return VersionTuple(5);
14551455
case Triple::DriverKit:
1456-
// DriverKit always uses the build version load command.
1457-
return VersionTuple();
1456+
case Triple::BridgeOS:
14581457
case Triple::XROS:
1459-
// XROS always uses the build version load command.
1458+
// DriverKit/BridgeOS/XROS always use the build version load command.
14601459
return VersionTuple();
14611460
default:
14621461
break;
@@ -1487,6 +1486,8 @@ getMachoBuildVersionPlatformType(const Triple &Target) {
14871486
case Triple::XROS:
14881487
return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
14891488
: MachO::PLATFORM_XROS;
1489+
case Triple::BridgeOS:
1490+
return MachO::PLATFORM_BRIDGEOS;
14901491
default:
14911492
break;
14921493
}
@@ -1520,6 +1521,7 @@ void MCStreamer::emitVersionForTarget(
15201521
Version = Target.getDriverKitVersion();
15211522
break;
15221523
case Triple::XROS:
1524+
case Triple::BridgeOS:
15231525
Version = Target.getOSVersion();
15241526
break;
15251527
default:

llvm/test/CodeGen/AArch64/exp10-libcall-names.ll

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
; RUN: llc -mtriple=arm64-apple-driverkit < %s | FileCheck -check-prefix=APPLE %s
1111
; RUN: llc -mtriple=arm64-apple-driverkit1.0 < %s | FileCheck -check-prefix=APPLE %s
1212
; RUN: llc -mtriple=arm64-apple-driverkit24.0 < %s | FileCheck -check-prefix=APPLE %s
13-
; RUN: llc -mtriple=arm64-apple-bridgeos < %s | FileCheck -check-prefix=BRIDGEOS %s
14-
; RUN: llc -mtriple=arm64-apple-bridgeos1.0 < %s | FileCheck -check-prefix=BRIDGEOS %s
15-
; RUN: llc -mtriple=arm64-apple-bridgeos9.0 < %s | FileCheck -check-prefix=BRIDGEOS %s
13+
; RUN: llc -mtriple=arm64-apple-bridgeos < %s | FileCheck -check-prefix=APPLE %s
14+
; RUN: llc -mtriple=arm64-apple-bridgeos1.0 < %s | FileCheck -check-prefix=APPLE %s
15+
; RUN: llc -mtriple=arm64-apple-bridgeos9.0 < %s | FileCheck -check-prefix=APPLE %s
1616

1717
; RUN: not llc -mtriple=aarch64-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
1818
; 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) {
2929
; APPLE-LABEL: test_exp10_f32:
3030
; APPLE: ; %bb.0:
3131
; APPLE-NEXT: b ___exp10f
32-
;
33-
; BRIDGEOS-LABEL: test_exp10_f32:
34-
; BRIDGEOS: // %bb.0:
35-
; BRIDGEOS-NEXT: b __exp10f
36-
;
3732
%ret = call float @llvm.exp10.f32(float %x)
3833
ret float %ret
3934
}
@@ -46,11 +41,6 @@ define double @test_exp10_f64(double %x) {
4641
; APPLE-LABEL: test_exp10_f64:
4742
; APPLE: ; %bb.0:
4843
; APPLE-NEXT: b ___exp10
49-
;
50-
; BRIDGEOS-LABEL: test_exp10_f64:
51-
; BRIDGEOS: // %bb.0:
52-
; BRIDGEOS-NEXT: b __exp10
53-
;
5444
%ret = call double @llvm.exp10.f64(double %x)
5545
ret double %ret
5646
}

llvm/unittests/TargetParser/TripleTest.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,44 @@ TEST(TripleTest, XROS) {
22812281
EXPECT_EQ(VersionTuple(17), Version);
22822282
}
22832283

2284+
TEST(TripleTest, BridgeOS) {
2285+
Triple T;
2286+
VersionTuple Version;
2287+
2288+
T = Triple("arm64-apple-bridgeos");
2289+
EXPECT_TRUE(T.isBridgeOS());
2290+
EXPECT_FALSE(T.isXROS());
2291+
EXPECT_TRUE(T.isOSDarwin());
2292+
EXPECT_FALSE(T.isiOS());
2293+
EXPECT_FALSE(T.isMacOSX());
2294+
EXPECT_FALSE(T.isSimulatorEnvironment());
2295+
EXPECT_EQ(T.getOSName(), "bridgeos");
2296+
Version = T.getOSVersion();
2297+
EXPECT_EQ(VersionTuple(0), Version);
2298+
2299+
T = Triple("arm64-apple-bridgeos1.0");
2300+
EXPECT_TRUE(T.isBridgeOS());
2301+
EXPECT_FALSE(T.isXROS());
2302+
EXPECT_TRUE(T.isOSDarwin());
2303+
EXPECT_FALSE(T.isiOS());
2304+
EXPECT_FALSE(T.isMacOSX());
2305+
EXPECT_FALSE(T.isSimulatorEnvironment());
2306+
EXPECT_EQ(T.getOSName(), "bridgeos1.0");
2307+
Version = T.getOSVersion();
2308+
EXPECT_EQ(VersionTuple(1), Version);
2309+
2310+
T = Triple("arm64-apple-bridgeos9.0");
2311+
EXPECT_TRUE(T.isBridgeOS());
2312+
EXPECT_FALSE(T.isXROS());
2313+
EXPECT_TRUE(T.isOSDarwin());
2314+
EXPECT_FALSE(T.isiOS());
2315+
EXPECT_FALSE(T.isMacOSX());
2316+
EXPECT_FALSE(T.isSimulatorEnvironment());
2317+
EXPECT_EQ(T.getOSName(), "bridgeos9.0");
2318+
Version = T.getOSVersion();
2319+
EXPECT_EQ(VersionTuple(9), Version);
2320+
}
2321+
22842322
TEST(TripleTest, getOSVersion) {
22852323
Triple T;
22862324
VersionTuple Version;

0 commit comments

Comments
 (0)