[PATCH] [PPC64]: Add support for Swift calling convention

Andrew Jeffery via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 5 18:56:12 PDT 2017


Ping - Is anyone happy to review or apply the patch?

If I've missed some process I should have followed, please let me know!

Andrew

On Wed, 2017-03-22 at 22:30 +1030, Andrew Jeffery wrote:
> Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
> ---
>  lib/Basic/Targets.cpp      | 11 +++++++++++
>  lib/CodeGen/TargetInfo.cpp | 14 ++++++++++++--
>  2 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
> index fdedd91a3e15..6d7f37f2479a 100644
> --- a/lib/Basic/Targets.cpp
> +++ b/lib/Basic/Targets.cpp
> @@ -1708,6 +1708,17 @@ public:
>      }
>      return false;
>    }
> +
> +  CallingConvCheckResult checkCallingConvention(CallingConv CC)
> const override {
> +    switch (CC) {
> +    case CC_C:
> +    case CC_Swift:
> +        return CCCR_OK;
> +    default:
> +        break;
> +    }
> +    return CCCR_Warning;
> +  }
>  };
>  
>  class DarwinPPC32TargetInfo : public
> DarwinTargetInfo<PPC32TargetInfo> {
> diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
> index d2fc3888ef29..6193f6c4ac29 100644
> --- a/lib/CodeGen/TargetInfo.cpp
> +++ b/lib/CodeGen/TargetInfo.cpp
> @@ -4175,7 +4175,7 @@
> PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunct
> ion &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,
> @@ -4219,7 +4219,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;
> @@ -4262,6 +4262,16 @@ public:
>  
>    Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
>                      QualType Ty) const override;
> +
> +  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
> +                                    ArrayRef<llvm::Type*> scalars,
> +                                    bool asReturnValue) const
> override {
> +    return occupiesMoreThan(CGT, scalars, /*total*/ 4);
> +  }
> +
> +  bool isSwiftErrorInRegister() const override {
> +    return true;
> +  }
>  };
>  
>  class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170406/f802d126/attachment-0001.sig>


More information about the cfe-commits mailing list