llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-powerpc Author: Alsey Coleman Miller (colemancda) <details> <summary>Changes</summary> Adds Swift calling-convention (swiftcc/swifttailcc) support to the 32-bit PowerPC SVR4/EABI target. Without it, clang aborts with "Swift ABI info has not been initialized" because the 32-bit PowerPC target registered no SwiftABIInfo, which prevents Swift (e.g. Embedded Swift) from targeting 32-bit PowerPC platforms such as the Nintendo Wii/GameCube (PPC750). Mirrors the existing X86-32, ARM, AArch64 and 64-bit PowerPC handling. --- Full diff: https://github.com/llvm/llvm-project/pull/205457.diff 3 Files Affected: - (modified) clang/lib/Basic/Targets/PPC.h (+11) - (modified) clang/lib/CodeGen/Targets/PPC.cpp (+15-1) - (modified) llvm/lib/Target/PowerPC/PPCISelLowering.cpp (+4-3) ``````````diff 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); `````````` </details> https://github.com/llvm/llvm-project/pull/205457 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
