https://github.com/kubamracek created https://github.com/llvm/llvm-project/pull/71986
With Embedded Swift, <https://forums.swift.org/t/embedded-swift/67057>, it becomes possible and useful to produce Swift code for a whole range of CPU targets. This change allows using the 'swiftcall' and 'swiftasynccall)' attributes on any Clang supported target. This isn't in any way adding complete support for those calling conventions for all targets, it's merely removing one obstacle from adding new targets to Swift. >From d2df2830b4417c0ecc9690c4092053bf465a5d44 Mon Sep 17 00:00:00 2001 From: Kuba Mracek <mra...@apple.com> Date: Fri, 10 Nov 2023 13:25:13 -0800 Subject: [PATCH] [clang] Allow __attribute__((swiftcall)) on all targets With Embedded Swift, <https://forums.swift.org/t/embedded-swift/67057>, it becomes possible and useful to produce Swift code for a whole range of CPU targets. This change allows using the 'swiftcall' and 'swiftasynccall)' attributes on any Clang supported target. This isn't in any way adding complete support for those calling conventions for all targets, it's merely removing one obstacle from adding new targets to Swift. --- clang/include/clang/Basic/TargetInfo.h | 2 ++ clang/lib/CodeGen/ABIInfo.cpp | 4 ++++ clang/lib/CodeGen/ABIInfo.h | 1 + clang/lib/CodeGen/TargetInfo.cpp | 4 +++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 41f3c2e403cbef6..308d2ae830bf263 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1606,6 +1606,8 @@ class TargetInfo : public TransferrableTargetInfo, default: return CCCR_Warning; case CC_C: + case CC_Swift: + case CC_SwiftAsync: return CCCR_OK; } } diff --git a/clang/lib/CodeGen/ABIInfo.cpp b/clang/lib/CodeGen/ABIInfo.cpp index 1b56cf7c596d067..86897504b0ad267 100644 --- a/clang/lib/CodeGen/ABIInfo.cpp +++ b/clang/lib/CodeGen/ABIInfo.cpp @@ -33,6 +33,10 @@ const CodeGenOptions &ABIInfo::getCodeGenOpts() const { return CGT.getCodeGenOpts(); } +CodeGen::CodeGenTypes &ABIInfo::getCodeGenTypes() const { + return CGT; +} + bool ABIInfo::isAndroid() const { return getTarget().getTriple().isAndroid(); } bool ABIInfo::isOHOSFamily() const { diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h index b9a5ef6e4366936..99b262bdb529684 100644 --- a/clang/lib/CodeGen/ABIInfo.h +++ b/clang/lib/CodeGen/ABIInfo.h @@ -60,6 +60,7 @@ class ABIInfo { const llvm::DataLayout &getDataLayout() const; const TargetInfo &getTarget() const; const CodeGenOptions &getCodeGenOpts() const; + CodeGen::CodeGenTypes &getCodeGenTypes() const; /// Return the calling convention to use for system runtime /// functions. diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 3d79f92137abc79..fdcf77ef9ce547c 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -67,7 +67,9 @@ LLVM_DUMP_METHOD void ABIArgInfo::dump() const { } TargetCodeGenInfo::TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info) - : Info(std::move(Info)) {} + : Info(std::move(Info)), + SwiftInfo(std::make_unique<SwiftABIInfo>( + this->Info->getCodeGenTypes(), /*SwiftErrorInRegister*/ false)) {} TargetCodeGenInfo::~TargetCodeGenInfo() = default; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits