[clang] [clang] Add Swift support for MIPS (PR #205461)
Alsey Coleman Miller via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 17:52:46 PDT 2026
https://github.com/colemancda created https://github.com/llvm/llvm-project/pull/205461
Adds support for compiling Swift targeting the MIPS ABI.
Related to https://github.com/swiftlang/swift/issues/58204
>From 7f8304924a20b5c0fb2bb861b02633632308bdd9 Mon Sep 17 00:00:00 2001
From: Alsey Coleman Miller <alseycmiller at gmail.com>
Date: Tue, 23 Jun 2026 20:50:46 -0400
Subject: [PATCH] [clang] Add Swift support for MIPS
Adds support for compiling Swift targeting the MIPS ABI
---
clang/lib/Basic/Targets/Mips.h | 11 +++++++++++
clang/lib/CodeGen/Targets/Mips.cpp | 5 ++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 2f251c7eb8690..ebdd7d083709b 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -433,6 +433,17 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
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;
+ }
+ }
};
class LLVM_LIBRARY_VISIBILITY WindowsMipsTargetInfo
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp b/clang/lib/CodeGen/Targets/Mips.cpp
index 22fdcd95ea8fa..3693e5dbfa91c 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -44,7 +44,10 @@ class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
public:
MIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32)
: TargetCodeGenInfo(std::make_unique<MipsABIInfo>(CGT, IsO32)),
- SizeOfUnwindException(IsO32 ? 24 : 32) {}
+ SizeOfUnwindException(IsO32 ? 24 : 32) {
+ SwiftInfo =
+ std::make_unique<SwiftABIInfo>(CGT, /*SwiftErrorInRegister=*/false);
+ }
int getDwarfEHStackPointer(CodeGen::CodeGenModule &CGM) const override {
return 29;
More information about the cfe-commits
mailing list