https://github.com/colemancda updated 
https://github.com/llvm/llvm-project/pull/205457

>From 40d408ccabaa83b656a2fcd91786977cd5b9a964 Mon Sep 17 00:00:00 2001
From: Alsey Coleman Miller <[email protected]>
Date: Tue, 23 Jun 2026 20:00:20 -0400
Subject: [PATCH] [clang] Support the Swift calling convention on 32-bit
 PowerPC

---
 clang/lib/Basic/Targets/PPC.h               | 11 +++++++++++
 clang/lib/CodeGen/Targets/PPC.cpp           | 16 +++++++++++++++-
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp |  7 ++++---
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index e3bf5072d932d..165de12118eb8 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -433,6 +433,17 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public 
PPCTargetInfo {
   std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
     return std::make_pair(32, 32);
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+    switch (CC) {
+    case CC_Swift:
+      return CCCR_OK;
+    case CC_SwiftAsync:
+      return CCCR_Error;
+    default:
+      return CCCR_Warning;
+    }
+  }
 };
 
 // Note: ABI differences may eventually require us to have a separate
diff --git a/clang/lib/CodeGen/Targets/PPC.cpp 
b/clang/lib/CodeGen/Targets/PPC.cpp
index ab069bfbd1b51..9024f9934c37e 100644
--- a/clang/lib/CodeGen/Targets/PPC.cpp
+++ b/clang/lib/CodeGen/Targets/PPC.cpp
@@ -382,12 +382,26 @@ class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
                    AggValueSlot Slot) const override;
 };
 
+/// Swift calling convention ABI for 32-bit PowerPC (SVR4/EABI).
+class PPC32SwiftABIInfo : public SwiftABIInfo {
+public:
+  explicit PPC32SwiftABIInfo(CodeGenTypes &CGT)
+      : SwiftABIInfo(CGT, /*SwiftErrorInRegister=*/false) {}
+
+  bool shouldPassIndirectly(ArrayRef<llvm::Type *> ComponentTys,
+                            bool AsReturnValue) const override {
+    return occupiesMoreThan(ComponentTys, /*total=*/4);
+  }
+};
+
 class PPC32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   PPC32TargetCodeGenInfo(CodeGenTypes &CGT, bool SoftFloatABI,
                          bool RetSmallStructInRegABI)
       : TargetCodeGenInfo(std::make_unique<PPC32_SVR4_ABIInfo>(
-            CGT, SoftFloatABI, RetSmallStructInRegABI)) {}
+            CGT, SoftFloatABI, RetSmallStructInRegABI)) {
+    SwiftInfo = std::make_unique<PPC32SwiftABIInfo>(CGT);
+  }
 
   static bool isStructReturnInRegABI(const llvm::Triple &Triple,
                                      const CodeGenOptions &Opts);
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 76cc06f2b4ed9..1c30846a3182c 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -5978,9 +5978,10 @@ SDValue PPCTargetLowering::LowerCall_32SVR4(
   const bool IsVarArg = CFlags.IsVarArg;
   const bool IsTailCall = CFlags.IsTailCall;
 
-  assert((CallConv == CallingConv::C ||
-          CallConv == CallingConv::Cold ||
-          CallConv == CallingConv::Fast) && "Unknown calling convention!");
+  assert((CallConv == CallingConv::C || CallConv == CallingConv::Cold ||
+          CallConv == CallingConv::Fast || CallConv == CallingConv::Swift ||
+          CallConv == CallingConv::SwiftTail) &&
+         "Unknown calling convention!");
 
   const Align PtrAlign(4);
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to