r251708 - Watch and TV OS: wire up basic ABI choices
Tim Northover via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 30 09:30:37 PDT 2015
Author: tnorthover
Date: Fri Oct 30 11:30:36 2015
New Revision: 251708
URL: http://llvm.org/viewvc/llvm-project?rev=251708&view=rev
Log:
Watch and TV OS: wire up basic ABI choices
This sets the mostly expected Darwin default ABI options for these two
platforms. Active changes from these defaults for watchOS are in a later patch.
Modified:
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/include/clang/Basic/TargetCXXABI.h
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/ObjCRuntime.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/ios-simulator-arcruntime.c
Modified: cfe/trunk/include/clang/Basic/ObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ObjCRuntime.h?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/ObjCRuntime.h (original)
+++ cfe/trunk/include/clang/Basic/ObjCRuntime.h Fri Oct 30 11:30:36 2015
@@ -41,6 +41,10 @@ public:
/// version of iOS.
iOS,
+ /// 'watchos' is a variant of iOS for Apple's watchOS. The version
+ /// is a release version of watchOS.
+ WatchOS,
+
/// 'gcc' is the Objective-C runtime shipped with GCC, implementing a
/// fragile Objective-C ABI
GCC,
@@ -81,6 +85,7 @@ public:
case GNUstep: return true;
case ObjFW: return true;
case iOS: return true;
+ case WatchOS: return true;
}
llvm_unreachable("bad kind");
}
@@ -114,6 +119,7 @@ public:
case FragileMacOSX:
case MacOSX:
case iOS:
+ case WatchOS:
return false;
case GCC:
case GNUstep:
@@ -138,6 +144,7 @@ public:
return getVersion() >= VersionTuple(10, 7);
case MacOSX: return true;
case iOS: return true;
+ case WatchOS: return true;
case GCC: return false;
case GNUstep: return true;
case ObjFW: return true;
@@ -155,6 +162,7 @@ public:
case FragileMacOSX: return getVersion() >= VersionTuple(10, 7);
case MacOSX: return getVersion() >= VersionTuple(10, 7);
case iOS: return getVersion() >= VersionTuple(5);
+ case WatchOS: return true;
case GCC: return false;
case GNUstep: return getVersion() >= VersionTuple(1, 6);
@@ -170,6 +178,8 @@ public:
return getVersion() >= VersionTuple(10, 8);
case iOS:
return (getVersion() >= VersionTuple(6));
+ case WatchOS:
+ return true;
case GNUstep:
return getVersion() >= VersionTuple(1, 7);
@@ -199,6 +209,7 @@ public:
case FragileMacOSX: return false;
case MacOSX: return getVersion() >= VersionTuple(10, 8);
case iOS: return getVersion() >= VersionTuple(6);
+ case WatchOS: return true;
// This is really a lie, because some implementations and versions
// of the runtime do not support ARC. Probably -fgnu-runtime
@@ -226,6 +237,7 @@ public:
return true;
case MacOSX:
case iOS:
+ case WatchOS:
case GNUstep:
case ObjFW:
return false;
@@ -247,6 +259,7 @@ public:
case FragileMacOSX: return getVersion() >= VersionTuple(10, 8);
case MacOSX: return getVersion() >= VersionTuple(10, 8);
case iOS: return getVersion() >= VersionTuple(5);
+ case WatchOS: return true;
case GCC: return false;
case GNUstep: return false;
case ObjFW: return false;
@@ -259,6 +272,7 @@ public:
switch (getKind()) {
case MacOSX: return true;
case iOS: return true;
+ case WatchOS: return true;
case FragileMacOSX: return false;
case GCC: return true;
case GNUstep: return true;
@@ -272,6 +286,7 @@ public:
switch (getKind()) {
case MacOSX: return true;
case iOS: return true;
+ case WatchOS: return true;
case FragileMacOSX: return false;
case GCC: return true;
case GNUstep: return true;
@@ -285,6 +300,7 @@ public:
case FragileMacOSX:
case MacOSX:
case iOS:
+ case WatchOS:
return true;
case GNUstep:
return getVersion() >= VersionTuple(1, 7);
Modified: cfe/trunk/include/clang/Basic/TargetCXXABI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetCXXABI.h?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetCXXABI.h (original)
+++ cfe/trunk/include/clang/Basic/TargetCXXABI.h Fri Oct 30 11:30:36 2015
@@ -71,6 +71,11 @@ public:
/// /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf
iOS64,
+ /// WatchOS is a modernisation of the iOS ABI, which roughly means it's
+ /// the iOS64 ABI ported to 32-bits. The primary difference from iOS64 is
+ /// that RTTI objects must still be unique at the moment.
+ WatchOS,
+
/// The generic AArch64 ABI is also a modified version of the Itanium ABI,
/// but it has fewer divergences than the 32-bit ARM ABI.
///
@@ -135,6 +140,7 @@ public:
case GenericARM:
case iOS:
case iOS64:
+ case WatchOS:
case GenericMIPS:
case WebAssembly:
return true;
@@ -153,6 +159,7 @@ public:
case GenericARM:
case iOS:
case iOS64:
+ case WatchOS:
case GenericMIPS:
case WebAssembly:
return false;
@@ -186,6 +193,7 @@ public:
case GenericItanium:
case iOS:
case iOS64:
+ case WatchOS:
case Microsoft:
return true;
}
@@ -261,6 +269,7 @@ public:
case GenericARM:
case iOS64:
case WebAssembly:
+ case WatchOS:
return false;
case GenericAArch64:
@@ -320,6 +329,7 @@ public:
// the Itanium exception about classes with over-large bitfields.
case iOS64:
case WebAssembly:
+ case WatchOS:
return UseTailPaddingUnlessPOD11;
// MSVC always allocates fields in the tail-padding of a base class
Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Fri Oct 30 11:30:36 2015
@@ -153,6 +153,9 @@ static bool HasARCRuntime(CompilerInvoca
if (triple.isiOS())
return triple.getOSMajorVersion() >= 5;
+ if (triple.isWatchOS())
+ return true;
+
if (triple.getOS() == llvm::Triple::Darwin)
return triple.getOSMajorVersion() >= 11;
Modified: cfe/trunk/lib/ARCMigrate/Transforms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.cpp Fri Oct 30 11:30:36 2015
@@ -50,7 +50,8 @@ bool trans::canApplyWeak(ASTContext &Ctx
return false;
// iOS is always safe to use 'weak'.
- if (Ctx.getTargetInfo().getTriple().isiOS())
+ if (Ctx.getTargetInfo().getTriple().isiOS() ||
+ Ctx.getTargetInfo().getTriple().isWatchOS())
AllowOnUnknownClass = true;
while (const PointerType *ptr = T->getAs<PointerType>())
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Oct 30 11:30:36 2015
@@ -683,6 +683,7 @@ CXXABI *ASTContext::createCXXABI(const T
case TargetCXXABI::GenericARM: // Same as Itanium at this level
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
+ case TargetCXXABI::WatchOS:
case TargetCXXABI::GenericAArch64:
case TargetCXXABI::GenericMIPS:
case TargetCXXABI::GenericItanium:
@@ -8496,6 +8497,7 @@ MangleContext *ASTContext::createMangleC
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
case TargetCXXABI::WebAssembly:
+ case TargetCXXABI::WatchOS:
return ItaniumMangleContext::create(*this, getDiagnostics());
case TargetCXXABI::Microsoft:
return MicrosoftMangleContext::create(*this, getDiagnostics());
Modified: cfe/trunk/lib/Basic/ObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/ObjCRuntime.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/ObjCRuntime.cpp (original)
+++ cfe/trunk/lib/Basic/ObjCRuntime.cpp Fri Oct 30 11:30:36 2015
@@ -30,6 +30,7 @@ raw_ostream &clang::operator<<(raw_ostre
case ObjCRuntime::MacOSX: out << "macosx"; break;
case ObjCRuntime::FragileMacOSX: out << "macosx-fragile"; break;
case ObjCRuntime::iOS: out << "ios"; break;
+ case ObjCRuntime::WatchOS: out << "watchos"; break;
case ObjCRuntime::GNUstep: out << "gnustep"; break;
case ObjCRuntime::GCC: out << "gcc"; break;
case ObjCRuntime::ObjFW: out << "objfw"; break;
@@ -62,6 +63,8 @@ bool ObjCRuntime::tryParse(StringRef inp
kind = ObjCRuntime::FragileMacOSX;
} else if (runtimeName == "ios") {
kind = ObjCRuntime::iOS;
+ } else if (runtimeName == "watchos") {
+ kind = ObjCRuntime::WatchOS;
} else if (runtimeName == "gnustep") {
// If no version is specified then default to the most recent one that we
// know about.
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Oct 30 11:30:36 2015
@@ -19,6 +19,7 @@
#include "clang/Basic/MacroBuilder.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetOptions.h"
+#include "clang/Basic/Version.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
@@ -4464,7 +4465,9 @@ public:
//
// FIXME: We need support for -meabi... we could just mangle it into the
// name.
- if (Name == "apcs-gnu") {
+ // FIXME: aapcs16 isn't really the same as APCS, this allows tests to pass
+ // until the real ABI is committed.
+ if (Name == "apcs-gnu" || Name == "aapcs16") {
setABIAPCS();
return true;
}
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Oct 30 11:30:36 2015
@@ -129,6 +129,7 @@ static const EHPersonality &getObjCPerso
return getCPersonality(T, L);
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
+ case ObjCRuntime::WatchOS:
return EHPersonality::NeXT_ObjC;
case ObjCRuntime::GNUstep:
if (L.ObjCRuntime.getVersion() >= VersionTuple(1, 7))
@@ -160,6 +161,7 @@ static const EHPersonality &getObjCXXPer
// function on targets using (backend-driven) SJLJ EH.
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
+ case ObjCRuntime::WatchOS:
return EHPersonality::NeXT_ObjC;
// In the fragile ABI, just use C++ exception handling and hope
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Fri Oct 30 11:30:36 2015
@@ -2889,6 +2889,7 @@ clang::CodeGen::CreateGNUObjCRuntime(Cod
case ObjCRuntime::FragileMacOSX:
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
+ case ObjCRuntime::WatchOS:
llvm_unreachable("these runtimes are not GNU runtimes");
}
llvm_unreachable("bad runtime");
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Oct 30 11:30:36 2015
@@ -4489,7 +4489,7 @@ void CGObjCCommonMac::EmitImageInfo() {
// Indicate whether we're compiling this to run on a simulator.
const llvm::Triple &Triple = CGM.getTarget().getTriple();
- if (Triple.isiOS() &&
+ if ((Triple.isiOS() || Triple.isWatchOS()) &&
(Triple.getArch() == llvm::Triple::x86 ||
Triple.getArch() == llvm::Triple::x86_64))
Mod.addModuleFlag(llvm::Module::Error, "Objective-C Is Simulated",
@@ -5902,7 +5902,8 @@ void CGObjCNonFragileABIMac::GenerateCla
// Make this entry NULL for any iOS device target, any iOS simulator target,
// OS X with deployment target 10.9 or later.
const llvm::Triple &Triple = CGM.getTarget().getTriple();
- if (Triple.isiOS() || (Triple.isMacOSX() && !Triple.isMacOSXVersionLT(10, 9)))
+ if (Triple.isiOS() || Triple.isWatchOS() ||
+ (Triple.isMacOSX() && !Triple.isMacOSXVersionLT(10, 9)))
// This entry will be null.
ObjCEmptyVtableVar = nullptr;
else
@@ -7224,6 +7225,7 @@ CodeGen::CreateMacObjCRuntime(CodeGen::C
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
+ case ObjCRuntime::WatchOS:
return new CGObjCNonFragileABIMac(CGM);
case ObjCRuntime::GNUstep:
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Oct 30 11:30:36 2015
@@ -65,6 +65,7 @@ static CGCXXABI *createCXXABI(CodeGenMod
case TargetCXXABI::GenericARM:
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
+ case TargetCXXABI::WatchOS:
case TargetCXXABI::GenericMIPS:
case TargetCXXABI::GenericItanium:
case TargetCXXABI::WebAssembly:
@@ -187,6 +188,7 @@ void CodeGenModule::createObjCRuntime()
case ObjCRuntime::FragileMacOSX:
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
+ case ObjCRuntime::WatchOS:
ObjCRuntime = CreateMacObjCRuntime(*this);
return;
}
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Fri Oct 30 11:30:36 2015
@@ -461,6 +461,7 @@ CodeGen::CGCXXABI *CodeGen::CreateItaniu
// between the ARM and iOS ABIs.
case TargetCXXABI::GenericARM:
case TargetCXXABI::iOS:
+ case TargetCXXABI::WatchOS:
return new ARMCXXABI(CGM);
case TargetCXXABI::iOS64:
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Oct 30 11:30:36 2015
@@ -68,9 +68,7 @@ bool MachO::HasNativeLLVMSupport() const
/// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const {
if (isTargetWatchOSBased())
- // FIXME: not quite iOS because of version mismatch. Choose something for
- // now.
- return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
+ return ObjCRuntime(ObjCRuntime::WatchOS, TargetVersion);
if (isTargetIOSBased())
return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
if (isNonFragile)
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 30 11:30:36 2015
@@ -611,11 +611,15 @@ arm::FloatABI arm::getARMFloatABI(const
switch (Triple.getOS()) {
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
- case llvm::Triple::IOS: {
+ case llvm::Triple::IOS:
+ case llvm::Triple::TvOS: {
// Darwin defaults to "softfp" for v6 and v7.
ABI = (SubArch == 6 || SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
break;
}
+ case llvm::Triple::WatchOS:
+ ABI = FloatABI::Hard;
+ break;
// FIXME: this is invalid for WindowsCE
case llvm::Triple::Win32:
@@ -803,7 +807,8 @@ static void getARMTargetFeatures(const T
options::OPT_mno_long_calls)) {
if (A->getOption().matches(options::OPT_mlong_calls))
Features.push_back("+long-calls");
- } else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6))) {
+ } else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
+ !Triple.isWatchOS()) {
Features.push_back("+long-calls");
}
@@ -866,6 +871,8 @@ void Clang::AddARMTargetArgs(const llvm:
} else if (Triple.isOSBinFormatMachO()) {
if (useAAPCSForMachO(Triple)) {
ABIName = "aapcs";
+ } else if (Triple.isWatchOS()) {
+ ABIName = "aapcs16";
} else {
ABIName = "apcs-gnu";
}
Modified: cfe/trunk/test/Driver/ios-simulator-arcruntime.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ios-simulator-arcruntime.c?rev=251708&r1=251707&r2=251708&view=diff
==============================================================================
--- cfe/trunk/test/Driver/ios-simulator-arcruntime.c (original)
+++ cfe/trunk/test/Driver/ios-simulator-arcruntime.c Fri Oct 30 11:30:36 2015
@@ -6,3 +6,11 @@
// CHECK-OPTIONS1: -fobjc-runtime=ios-4.2.1
// CHECK-OPTIONS2: i386-apple-ios5.0.0
// CHECK-OPTIONS2: -fobjc-runtime=ios-5.0.0
+
+// RUN: %clang -### -x objective-c -target x86_64-apple-darwin -mtvos-simulator-version-min=8.3.0 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS3 %s
+// CHECK-OPTIONS3: x86_64-apple-tvos8.3.0
+// CHECK-OPTIONS3: -fobjc-runtime=ios-8.3.0
+
+// RUN: %clang -### -x objective-c -target x86_64-apple-darwin -mwatchos-simulator-version-min=2.0.0 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS4 %s
+// CHECK-OPTIONS4: x86_64-apple-watchos2.0.0
+// CHECK-OPTIONS4: -fobjc-runtime=watchos-2.0.0
More information about the cfe-commits
mailing list