Skip to content

Commit c5bd3d0

Browse files
kateinoigakukundschuff
authored andcommitted
Support Swift calling convention for WebAssembly targets
This adds basic support for the Swift calling convention with WebAssembly targets. Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D71823
1 parent 37aa16e commit c5bd3d0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/Basic/Targets/WebAssembly.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
114114
? (IsSigned ? SignedLongLong : UnsignedLongLong)
115115
: TargetInfo::getLeastIntTypeByWidth(BitWidth, IsSigned);
116116
}
117+
118+
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
119+
switch (CC) {
120+
case CC_C:
121+
case CC_Swift:
122+
return CCCR_OK;
123+
default:
124+
return CCCR_Warning;
125+
}
126+
}
117127
};
118128
class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
119129
: public WebAssemblyTargetInfo {

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ static bool callingConvSupported(CallingConv::ID CallConv) {
672672
CallConv == CallingConv::PreserveMost ||
673673
CallConv == CallingConv::PreserveAll ||
674674
CallConv == CallingConv::CXX_FAST_TLS ||
675-
CallConv == CallingConv::WASM_EmscriptenInvoke;
675+
CallConv == CallingConv::WASM_EmscriptenInvoke ||
676+
CallConv == CallingConv::Swift;
676677
}
677678

678679
SDValue

0 commit comments

Comments
 (0)