Swift Calling Convetion: add support for AArch64.
authorManman Ren <manman.ren@gmail.com>
Fri, 26 Aug 2016 19:28:17 +0000 (19:28 +0000)
committerManman Ren <manman.ren@gmail.com>
Fri, 26 Aug 2016 19:28:17 +0000 (19:28 +0000)
It will just be the same as the regular calling convention.

rdar://28029509

llvm-svn: 279853

llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/swiftcc.ll [new file with mode: 0644]

index a2bb2b2..405e7d0 100644 (file)
@@ -2860,7 +2860,7 @@ bool AArch64FastISel::fastLowerArguments() {
     return false;
 
   CallingConv::ID CC = F->getCallingConv();
-  if (CC != CallingConv::C)
+  if (CC != CallingConv::C && CC != CallingConv::Swift)
     return false;
 
   // Only handle simple cases of up to 8 GPR and FPR each.
index 6ed9e6f..bdc9ca4 100644 (file)
@@ -2429,6 +2429,7 @@ CCAssignFn *AArch64TargetLowering::CCAssignFnForCall(CallingConv::ID CC,
   case CallingConv::Fast:
   case CallingConv::PreserveMost:
   case CallingConv::CXX_FAST_TLS:
+  case CallingConv::Swift:
     if (!Subtarget->isTargetDarwin())
       return CC_AArch64_AAPCS;
     return IsVarArg ? CC_AArch64_DarwinPCS_VarArg : CC_AArch64_DarwinPCS;
diff --git a/llvm/test/CodeGen/AArch64/swiftcc.ll b/llvm/test/CodeGen/AArch64/swiftcc.ll
new file mode 100644 (file)
index 0000000..4324954
--- /dev/null
@@ -0,0 +1,11 @@
+; RUN: llc -verify-machineinstrs -mtriple=aarch64-apple-ios -o - %s | FileCheck %s
+; RUN: llc -O0 -verify-machineinstrs -mtriple=aarch64-apple-ios -o - %s | FileCheck %s
+
+; CHECK: t1
+; CHECK: fadd s0, s0, s1
+; CHECK: ret
+define swiftcc float @t1(float %a, float %b) {
+entry:
+  %add = fadd float %a, %b
+  ret float %add
+}