OSDN Git Service

Support Swift calling convention for WebAssembly targets
authorYuta Saito <kateinoigakukun@gmail.com>
Fri, 24 Jan 2020 18:20:07 +0000 (10:20 -0800)
committerDerek Schuff <dschuff@chromium.org>
Fri, 24 Jan 2020 18:30:46 +0000 (10:30 -0800)
This adds basic support for the Swift calling convention with WebAssembly
targets.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D71823

clang/lib/Basic/Targets/WebAssembly.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

index 9665156..55d90db 100644 (file)
@@ -114,6 +114,16 @@ private:
                ? (IsSigned ? SignedLongLong : UnsignedLongLong)
                : TargetInfo::getLeastIntTypeByWidth(BitWidth, IsSigned);
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+    switch (CC) {
+    case CC_C:
+    case CC_Swift:
+      return CCCR_OK;
+    default:
+      return CCCR_Warning;
+    }
+  }
 };
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
     : public WebAssemblyTargetInfo {
index e91a9ea..12fad04 100644 (file)
@@ -672,7 +672,8 @@ static bool callingConvSupported(CallingConv::ID CallConv) {
          CallConv == CallingConv::PreserveMost ||
          CallConv == CallingConv::PreserveAll ||
          CallConv == CallingConv::CXX_FAST_TLS ||
-         CallConv == CallingConv::WASM_EmscriptenInvoke;
+         CallConv == CallingConv::WASM_EmscriptenInvoke ||
+         CallConv == CallingConv::Swift;
 }
 
 SDValue