[PATCH] D137512: [clang] Add Swift support for MIPS
Alsey Coleman Miller via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 6 16:32:33 PST 2022
colemancda created this revision.
Herald added subscribers: atanasyan, jrtc27, arichardson, sdardis.
Herald added a project: All.
colemancda requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Adds support for compiling Swift targeting the MIPS ABI
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137512
Files:
clang/lib/Basic/Targets/Mips.h
clang/lib/CodeGen/TargetInfo.cpp
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7704,7 +7704,7 @@
//===----------------------------------------------------------------------===//
namespace {
-class MipsABIInfo : public ABIInfo {
+class MipsABIInfo : public SwiftABIInfo {
bool IsO32;
unsigned MinABIStackAlignInBytes, StackAlignInBytes;
void CoerceToIntArgs(uint64_t TySize,
@@ -7713,9 +7713,10 @@
llvm::Type* returnAggregateInRegs(QualType RetTy, uint64_t Size) const;
llvm::Type* getPaddingType(uint64_t Align, uint64_t Offset) const;
public:
- MipsABIInfo(CodeGenTypes &CGT, bool _IsO32) :
- ABIInfo(CGT), IsO32(_IsO32), MinABIStackAlignInBytes(IsO32 ? 4 : 8),
- StackAlignInBytes(IsO32 ? 8 : 16) {}
+ MipsABIInfo(CodeGenTypes &CGT, bool _IsO32)
+ : SwiftABIInfo(CGT), IsO32(_IsO32),
+ MinABIStackAlignInBytes(IsO32 ? 4 : 8),
+ StackAlignInBytes(IsO32 ? 8 : 16) {}
ABIArgInfo classifyReturnType(QualType RetTy) const;
ABIArgInfo classifyArgumentType(QualType RetTy, uint64_t &Offset) const;
@@ -7723,6 +7724,14 @@
Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
QualType Ty) const override;
ABIArgInfo extendType(QualType Ty) const;
+
+private:
+ bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type *> scalars,
+ bool asReturnValue) const override {
+ return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+ }
+
+ bool isSwiftErrorInRegister() const override { return false; }
};
class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
Index: clang/lib/Basic/Targets/Mips.h
===================================================================
--- clang/lib/Basic/Targets/Mips.h
+++ clang/lib/Basic/Targets/Mips.h
@@ -407,6 +407,17 @@
bool validateTarget(DiagnosticsEngine &Diags) const override;
bool hasExtIntType() const override { return true; }
+
+ CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+ switch (CC) {
+ case CC_Swift:
+ return CCCR_OK;
+ case CC_SwiftAsync:
+ return CCCR_Error;
+ default:
+ return CCCR_Warning;
+ }
+ }
};
} // namespace targets
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137512.473520.patch
Type: text/x-patch
Size: 2306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221107/745293b8/attachment.bin>
More information about the cfe-commits
mailing list