ARM, AArch64: support `__attribute__((__swiftcall__))`
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 6 Dec 2018 03:28:37 +0000 (03:28 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 6 Dec 2018 03:28:37 +0000 (03:28 +0000)
Support the Swift calling convention on Windows ARM and AArch64.  Both
of these conform to the AAPCS, AAPCS64 calling convention, and LLVM has
been adjusted to account for the register usage.  Ensure that the
frontend passes this into the backend.  This allows the swift runtime to
be built for Windows.

llvm-svn: 348454

clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/ARM.cpp
clang/test/CodeGen/swift-call-conv.c [new file with mode: 0644]
clang/test/Sema/swift-call-conv.c [new file with mode: 0644]

index e64eb21..376cba6 100644 (file)
@@ -514,6 +514,7 @@ WindowsARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_Swift:
   case CC_Win64:
     return CCCR_OK;
   default:
index 5345d1f..cb202ea 100644 (file)
@@ -996,6 +996,7 @@ WindowsARMTargetInfo::checkCallingConvention(CallingConv CC) const {
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_Swift:
     return CCCR_OK;
   default:
     return CCCR_Warning;
diff --git a/clang/test/CodeGen/swift-call-conv.c b/clang/test/CodeGen/swift-call-conv.c
new file mode 100644 (file)
index 0000000..31d70b3
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm %s -o - | FileCheck %s
+
+// REQUIRES: aarch64-registered-target,arm-registered-target,x86-registered-target
+
+void __attribute__((__swiftcall__)) f(void) {}
+// CHECK-LABEL: define dso_local swiftcc void @f()
+
diff --git a/clang/test/Sema/swift-call-conv.c b/clang/test/Sema/swift-call-conv.c
new file mode 100644 (file)
index 0000000..755c18f
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fsyntax-only %s -verify
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fsyntax-only %s -verify
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fsyntax-only %s -verify
+
+// expected-no-diagnostics
+
+void __attribute__((__swiftcall__)) f(void) {}