Skip to content
Open
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
19 changes: 19 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
return "apple-m1";
}

if (Triple.getOS() == llvm::Triple::IOS) {
assert(!Triple.isSimulatorEnvironment() && "iossim should be mac-like");
// iOS 26 only runs on apple-a12 and later CPUs.
if (!Triple.isOSVersionLT(26))
return "apple-a12";
// arm64 (non-e) iOS 18 only runs on apple-a10 and later CPUs.
if (!Triple.isOSVersionLT(18) && !Triple.isArm64e())
return "apple-a10";
}

if (Triple.isWatchOS()) {
assert(!Triple.isSimulatorEnvironment() && "watchossim should be mac-like");
// arm64_32/arm64e watchOS requires S4 before watchOS 26, S6 after.
if (Triple.getArch() == llvm::Triple::aarch64_32 || Triple.isArm64e())
return Triple.isOSVersionLT(26) ? "apple-s4" : "apple-s6";
// arm64 (non-e, non-32) watchOS comes later, and requires S9 anyway.
return "apple-s9";
}

if (Triple.isXROS()) {
// The xrOS simulator runs on M1 as well, it should have been covered above.
assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");
Expand Down
28 changes: 28 additions & 0 deletions clang/test/Driver/aarch64-cpu-defaults-appleos26.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// iOS 26 and watchOS 26 bump the default arm64 CPU targets.

/// arm64 iOS 26 defaults to apple-a12. arm64e already did.
// RUN: %clang -target arm64-apple-ios26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12
// RUN: %clang -target arm64e-apple-ios26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12

/// iOS 18 came before iOS 26, compare its defaults.
// RUN: %clang -target arm64-apple-ios18 -### -c %s 2>&1 | FileCheck %s --check-prefix=A10
// RUN: %clang -target arm64e-apple-ios18 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12

/// arm64e/arm64_32 watchOS 26 default to apple-s6.
// RUN: %clang -target arm64e-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6
// RUN: %clang -target arm64_32-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S6

/// arm64 is new in watchOS 26, and defaults to apple-s9.
// RUN: %clang -target arm64-apple-watchos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=S9

/// llvm usually treats tvOS like iOS, but it runs on different hardware.
// RUN: %clang -target arm64-apple-tvos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A7
// RUN: %clang -target arm64e-apple-tvos26 -### -c %s 2>&1 | FileCheck %s --check-prefix=A12

/// Simulators are tested with other Mac-like targets in aarch64-mac-cpus.c.

// A12: "-target-cpu" "apple-a12"
// A10: "-target-cpu" "apple-a10"
// S6: "-target-cpu" "apple-s6"
// S9: "-target-cpu" "apple-s9"
// A7: "-target-cpu" "apple-a7"
2 changes: 1 addition & 1 deletion clang/test/Driver/aarch64-mac-cpus.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// arm64 Mac-based targets default to Apple A13.
// arm64/arm64e Mac-based targets default to Apple M1.

// RUN: %clang --target=arm64-apple-macos -### -c %s 2>&1 | FileCheck %s
// RUN: %clang --target=arm64-apple-ios-macabi -### -c %s 2>&1 | FileCheck %s
Expand Down