r348454 - ARM, AArch64: support `__attribute__((__swiftcall__))`

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 5 19:28:37 PST 2018


Author: compnerd
Date: Wed Dec  5 19:28:37 2018
New Revision: 348454

URL: http://llvm.org/viewvc/llvm-project?rev=348454&view=rev
Log:
ARM, AArch64: support `__attribute__((__swiftcall__))`

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.

Added:
    cfe/trunk/test/CodeGen/swift-call-conv.c
    cfe/trunk/test/Sema/swift-call-conv.c
Modified:
    cfe/trunk/lib/Basic/Targets/AArch64.cpp
    cfe/trunk/lib/Basic/Targets/ARM.cpp

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=348454&r1=348453&r2=348454&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Wed Dec  5 19:28:37 2018
@@ -514,6 +514,7 @@ WindowsARM64TargetInfo::checkCallingConv
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_Swift:
   case CC_Win64:
     return CCCR_OK;
   default:

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=348454&r1=348453&r2=348454&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Wed Dec  5 19:28:37 2018
@@ -996,6 +996,7 @@ WindowsARMTargetInfo::checkCallingConven
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_Swift:
     return CCCR_OK;
   default:
     return CCCR_Warning;

Added: cfe/trunk/test/CodeGen/swift-call-conv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/swift-call-conv.c?rev=348454&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/swift-call-conv.c (added)
+++ cfe/trunk/test/CodeGen/swift-call-conv.c Wed Dec  5 19:28:37 2018
@@ -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()
+

Added: cfe/trunk/test/Sema/swift-call-conv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/swift-call-conv.c?rev=348454&view=auto
==============================================================================
--- cfe/trunk/test/Sema/swift-call-conv.c (added)
+++ cfe/trunk/test/Sema/swift-call-conv.c Wed Dec  5 19:28:37 2018
@@ -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) {}




More information about the cfe-commits mailing list