diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/ABIInfo.h | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/SwiftCallingConv.cpp | 5 | ||||
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 21 |
3 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h index 530a7ef560c..ac31dfdaf3e 100644 --- a/clang/lib/CodeGen/ABIInfo.h +++ b/clang/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/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp index 1629c443652..0bfe30a32c8 100644 --- a/clang/lib/CodeGen/SwiftCallingConv.cpp +++ b/clang/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/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index caac27b965c..e4f7d99bef6 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/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 { |