Skip to content

Runtime should be updated to support the __vectorcall calling convention #8300

@tannergooding

Description

@tannergooding

Rationale

Today, the runtime supports the __fastcall calling convention, which not only allows interop with any native code that uses that calling convention but also allows it to take advantage of the additional registers that are available on the underlying architecture.

However, it means that operating with certain data types is still "sub-optimal".

Microsoft Windows provides the __vectorcall calling convention just for this purpose (https://msdn.microsoft.com/en-us/library/dn375768.aspx). It extends the existing __fastcall calling convention to additionally allow SIMD vector types and Homogeneous Vector Aggregate values to be passed via register rather than on the stack.

The System V AMD64 ABI already defines vector sized types (__m128, __m256) and supports passing them in register.

Proposal

The runtime should add support for the __vectorcall calling convention, not only to improve performance, but to also provide better interop with native code that uses it.

namespace System.Runtime.CompilerServices
{
+    public class CallConvVectorCall
+    {
+        // This type has no members and is identical in structure to other `CallConv*` types
+    }
}

Alternative API proposal

The __vectorcall calling convention could be exposed on System.Runtime.InteropServices.CallingConvention as VectorCall.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions