]> granicus.if.org Git - clang/commitdiff
Support Swift calling convention for PPC64 targets
authorBob Wilson <bob.wilson@apple.com>
Fri, 25 May 2018 21:26:03 +0000 (21:26 +0000)
committerBob Wilson <bob.wilson@apple.com>
Fri, 25 May 2018 21:26:03 +0000 (21:26 +0000)
This adds basic support for the Swift calling convention with PPC64 targets.
Patch provided by Atul Sowani in bug report #37223

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333316 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets/PPC.h
lib/CodeGen/TargetInfo.cpp

index 629e4cfefb2ea18a1e7a677663a3bc4187be527b..9ea100f0a1de53945899ab7c3fdad4342daa50ec 100644 (file)
@@ -335,6 +335,15 @@ public:
     }
     return false;
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+    switch (CC) {
+    case CC_Swift:
+      return CCCR_OK;
+    default:
+      return CCCR_Warning;
+    }
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinPPC32TargetInfo
index 4e25c72cfb63dc9e69564f15d8c578f9030d890b..3ec00553607cd116aaf0f0234230d9c2ec5ee213 100644 (file)
@@ -4287,7 +4287,7 @@ PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
 
 namespace {
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
-class PPC64_SVR4_ABIInfo : public ABIInfo {
+class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
 public:
   enum ABIKind {
     ELFv1 = 0,
@@ -4331,7 +4331,7 @@ private:
 public:
   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind, bool HasQPX,
                      bool SoftFloatABI)
-      : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
+      : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
         IsSoftFloatABI(SoftFloatABI) {}
 
   bool isPromotableTypeForABI(QualType Ty) const;
@@ -4374,6 +4374,15 @@ public:
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
                     QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type*> scalars,
+                                    bool asReturnValue) const override {
+    return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+    return false;
+  }
 };
 
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {