1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[Clang] Introduce Swift async calling convention.

This change is intended as initial setup. The plan is to add
more semantic checks later. I plan to update the documentation
as more semantic checks are added (instead of documenting the
details up front). Most of the code closely mirrors that for
the Swift calling convention. Three places are marked as
[FIXME: swiftasynccc]; those will be addressed once the
corresponding convention is introduced in LLVM.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D95561
This commit is contained in:
Varun Gandhi 2021-06-22 14:44:29 -07:00
parent aff94971f7
commit d697536ac9
5 changed files with 14 additions and 2 deletions

View File

@ -67,7 +67,8 @@ enum class CallingConv : uint8_t {
Eabi, Eabi,
Vectorcall, Vectorcall,
Regcall, Regcall,
Swift, // Clang-only Swift, // Clang-only
SwiftAsync, // Clang-only
}; };
enum class ReferenceKind : uint8_t { None, LValueRef, RValueRef }; enum class ReferenceKind : uint8_t { None, LValueRef, RValueRef };

View File

@ -1713,6 +1713,8 @@ CallingConv Demangler::demangleCallingConvention(StringView &MangledName) {
return CallingConv::Vectorcall; return CallingConv::Vectorcall;
case 'S': case 'S':
return CallingConv::Swift; return CallingConv::Swift;
case 'T':
return CallingConv::SwiftAsync;
} }
return CallingConv::None; return CallingConv::None;

View File

@ -110,6 +110,9 @@ static void outputCallingConvention(OutputStream &OS, CallingConv CC) {
case CallingConv::Swift: case CallingConv::Swift:
OS << "__attribute__((__swiftcall__)) "; OS << "__attribute__((__swiftcall__)) ";
break; break;
case CallingConv::SwiftAsync:
OS << "__attribute__((__swiftasynccall__)) ";
break;
default: default:
break; break;
} }

View File

@ -709,7 +709,10 @@ void MergeFunctions::writeThunk(Function *F, Function *G) {
CallInst *CI = Builder.CreateCall(F, Args); CallInst *CI = Builder.CreateCall(F, Args);
ReturnInst *RI = nullptr; ReturnInst *RI = nullptr;
CI->setTailCall(); bool isSwiftTailCall = F->getCallingConv() == CallingConv::SwiftTail &&
G->getCallingConv() == CallingConv::SwiftTail;
CI->setTailCallKind(isSwiftTailCall ? llvm::CallInst::TCK_MustTail
: llvm::CallInst::TCK_Tail);
CI->setCallingConv(F->getCallingConv()); CI->setCallingConv(F->getCallingConv());
CI->setAttributes(F->getAttributes()); CI->setAttributes(F->getAttributes());
if (H->getReturnType()->isVoidTy()) { if (H->getReturnType()->isVoidTy()) {

View File

@ -341,6 +341,9 @@
?swift_func@@YSXXZ ?swift_func@@YSXXZ
; CHECK: void __attribute__((__swiftcall__)) swift_func(void) ; CHECK: void __attribute__((__swiftcall__)) swift_func(void)
?swift_async_func@@YTXXZ
; CHECK: void __attribute__((__swiftasynccall__)) swift_async_func(void)
??$fn_tmpl@$1?extern_c_func@@YAXXZ@@YAXXZ ??$fn_tmpl@$1?extern_c_func@@YAXXZ@@YAXXZ
; CHECK: void __cdecl fn_tmpl<&void __cdecl extern_c_func(void)>(void) ; CHECK: void __cdecl fn_tmpl<&void __cdecl extern_c_func(void)>(void)