-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISC-V] FP structs larger than 16 bytes in interops #107386
Comments
Tagging subscribers to this area: @dotnet/interop-contrib |
Can we use custom marshalling to handle the specific layout and calling conventions required by the native side? Alternatively, a wrapper function on the native side that can handle the conversion between the .NET calling convention and the native calling convention? That wrapper would take the struct as passed by .NET, unpack it, and then repack it according to the native ABI expectations. |
I think it's not worth it, it's a corner-case achievable only by extra padding and the user has an easy (and cheaper performance-wise) way out of explicitly passing by |
@tomeksowi Is this issue for support or for an exception? It isn't clear based on title and the above comment in the description. |
Exception first, we can leave it open for visibility if anyone really needs it supported. |
.NET currently supports passing/returning structs according to hardware floating-point calling convention up to 16 bytes for reasons stated in #107286 (comment)
Native ABI does not limit size of FP structs so this won't work:
.NET will pass S according to integer calling convention (by implicit reference) and the native side will expect it in two registers, fa0 and a0.
Such structs are acheivable via empty structs, which are undefined in C, which ABI .NET interops follow. However, it would be nice to throw an exception if FP structs > 16 bytes appear in interops. (Things like
struct { _Alignas(16) double; long; }
are legal in C and .NET users may use empty structs to match the layout.)The text was updated successfully, but these errors were encountered: