[clang] [clang] Allow __attribute__((swiftcall)) on all targets (PR #71986)

2023-12-19 Thread Sergei Barannikov via cfe-commits

s-barannikov wrote:

I think the choice whether or not to support Swift calling convention should be 
made by individual targets without providing "safe" default. As pointed out in 
the linked PR, supporting Swift CC is not only about enabling the attribute 
support -- backend also needs modifications so that the calling convention is 
effective. This can only be done based on the ABI, which is target-dependent.


https://github.com/llvm/llvm-project/pull/71986
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow __attribute__((swiftcall)) on all targets (PR #71986)

2023-11-10 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 199fc973ced20016b04ba540cf63a1d4914fa513 
d2df2830b4417c0ecc9690c4092053bf465a5d44 -- 
clang/include/clang/Basic/TargetInfo.h clang/lib/CodeGen/ABIInfo.cpp 
clang/lib/CodeGen/ABIInfo.h clang/lib/CodeGen/TargetInfo.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/ABIInfo.cpp b/clang/lib/CodeGen/ABIInfo.cpp
index 86897504b..4608535a1 100644
--- a/clang/lib/CodeGen/ABIInfo.cpp
+++ b/clang/lib/CodeGen/ABIInfo.cpp
@@ -33,9 +33,7 @@ const CodeGenOptions ::getCodeGenOpts() const {
   return CGT.getCodeGenOpts();
 }
 
-CodeGen::CodeGenTypes ::getCodeGenTypes() const {
-  return CGT;
-}
+CodeGen::CodeGenTypes ::getCodeGenTypes() const { return CGT; }
 
 bool ABIInfo::isAndroid() const { return getTarget().getTriple().isAndroid(); }
 

``




https://github.com/llvm/llvm-project/pull/71986
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow __attribute__((swiftcall)) on all targets (PR #71986)

2023-11-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kuba (Brecka) Mracek (kubamracek)


Changes

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/71986.diff


4 Files Affected:

- (modified) clang/include/clang/Basic/TargetInfo.h (+2) 
- (modified) clang/lib/CodeGen/ABIInfo.cpp (+4) 
- (modified) clang/lib/CodeGen/ABIInfo.h (+1) 
- (modified) clang/lib/CodeGen/TargetInfo.cpp (+3-1) 


``diff
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 ::getCodeGenOpts() const {
   return CGT.getCodeGenOpts();
 }
 
+CodeGen::CodeGenTypes ::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 () const;
   const TargetInfo () const;
   const CodeGenOptions () const;
+  CodeGen::CodeGenTypes () 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 Info)
-: Info(std::move(Info)) {}
+: Info(std::move(Info)),
+  SwiftInfo(std::make_unique(
+  this->Info->getCodeGenTypes(), /*SwiftErrorInRegister*/ false)) {}
 
 TargetCodeGenInfo::~TargetCodeGenInfo() = default;
 

``




https://github.com/llvm/llvm-project/pull/71986
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow __attribute__((swiftcall)) on all targets (PR #71986)

2023-11-10 Thread Kuba Mracek via cfe-commits

https://github.com/kubamracek created 
https://github.com/llvm/llvm-project/pull/71986

With Embedded Swift, , 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 
Date: Fri, 10 Nov 2023 13:25:13 -0800
Subject: [PATCH] [clang] Allow __attribute__((swiftcall)) on all targets

With Embedded Swift, , 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 ::getCodeGenOpts() const {
   return CGT.getCodeGenOpts();
 }
 
+CodeGen::CodeGenTypes ::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 () const;
   const TargetInfo () const;
   const CodeGenOptions () const;
+  CodeGen::CodeGenTypes () 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 Info)
-: Info(std::move(Info)) {}
+: Info(std::move(Info)),
+  SwiftInfo(std::make_unique(
+  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