From: Arnold Schwaighofer Date: Thu, 1 Dec 2016 18:07:38 +0000 (+0000) Subject: swiftcc: Add an api to query whether a target ABI stores swifterror in a register X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5af66e97a414a1975bd277905c4b98fe74a345ce;p=clang swiftcc: Add an api to query whether a target ABI stores swifterror in a register git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288394 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/CodeGen/SwiftCallingConv.h b/include/clang/CodeGen/SwiftCallingConv.h index dd0ae2f1d6..23db43e673 100644 --- a/include/clang/CodeGen/SwiftCallingConv.h +++ b/include/clang/CodeGen/SwiftCallingConv.h @@ -160,6 +160,9 @@ ABIArgInfo classifyArgumentType(CodeGenModule &CGM, CanQualType type); /// private interface for Clang. void computeABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI); +/// Is swifterror lowered to a register by the target ABI. +bool isSwiftErrorLoweredInRegister(CodeGenModule &CGM); + } // end namespace swiftcall } // end namespace CodeGen } // end namespace clang diff --git a/lib/CodeGen/ABIInfo.h b/lib/CodeGen/ABIInfo.h index 530a7ef560..ac31dfdaf3 100644 --- a/lib/CodeGen/ABIInfo.h +++ b/lib/CodeGen/ABIInfo.h @@ -142,6 +142,8 @@ namespace swiftcall { llvm::Type *eltTy, unsigned elts) const; + virtual bool isSwiftErrorInRegister() const = 0; + static bool classof(const ABIInfo *info) { return info->supportsSwift(); } diff --git a/lib/CodeGen/SwiftCallingConv.cpp b/lib/CodeGen/SwiftCallingConv.cpp index 1629c44365..0bfe30a32c 100644 --- a/lib/CodeGen/SwiftCallingConv.cpp +++ b/lib/CodeGen/SwiftCallingConv.cpp @@ -828,3 +828,8 @@ void swiftcall::computeABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) { argInfo.info = classifyArgumentType(CGM, argInfo.type); } } + +// Is swifterror lowered to a register by the target ABI. +bool swiftcall::isSwiftErrorLoweredInRegister(CodeGenModule &CGM) { + return getSwiftABIInfo(CGM).isSwiftErrorInRegister(); +} diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index caac27b965..e4f7d99bef 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -958,6 +958,11 @@ public: // scalar registers. return occupiesMoreThan(CGT, scalars, /*total*/ 3); } + + bool isSwiftErrorInRegister() const override { + // x86-32 lowering does not support passing swifterror in a register. + return false; + } }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { @@ -2012,6 +2017,9 @@ public: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { + return true; + } }; /// WinX86_64ABIInfo - The Windows X86_64 ABI information. @@ -2043,6 +2051,10 @@ public: return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { + return true; + } + private: ABIArgInfo classify(QualType Ty, unsigned &FreeSSERegs, bool IsReturnType) const; @@ -4628,6 +4640,9 @@ private: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { + return true; + } }; class AArch64TargetCodeGenInfo : public TargetCodeGenInfo { @@ -5181,6 +5196,9 @@ private: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { + return true; + } }; class ARMTargetCodeGenInfo : public TargetCodeGenInfo { @@ -5949,6 +5967,9 @@ public: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { + return true; + } }; class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {