-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[vm/ffi] Support SSE & NEON packed data #37470
Comments
Issue specific for bit fields: #38954. |
Data TypesTypes taken from Intel: Packed integers:
Packed floats:
Packed doubles:
Calling ConventionsA packed float return value is passed in multiple XMM registers (in Clang 9): typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64)));
__m512 bla() {
__m512 x;
x[1] = 1.0f;
return x; // this return
}
int foo() {
float z = bla()[1];
return (z);
}
movaps xmm0, xmmword ptr [rsp]
movaps xmm1, xmmword ptr [rsp + 16]
movaps xmm2, xmmword ptr [rsp + 32]
movaps xmm3, xmmword ptr [rsp + 48]
mov rsp, rbp
pop rbp
ret This might have some overlap with how structs-by-value are passed (#36730). Native Memory AccessMemory access could be provided by regarding these as arrays. API DesignWe need Dart type to represent these types in function signatures for calling conventions. We can add extension methods for /// __m64
FloatX2 extends NativeType {}
extension FloatX2Pointer on Pointer<Float> {
external double operator [](int index);
external void operator []=(int index, double value);
} (Naming up for debate, cc @lrhn.) This design should work together with inline arrays (#35763): typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
struct MyStruct {
__m128 arr[4];
}; class MyStruct extends Struct {
@InlineArray(4)
Pointer<FloatX4> arr;
}
main() {
MyStruct m = //...
m.arr.elementAt(2)[2] = 1.0;
} Edit: Passing SSE data structures by value to functions requires stronger stack alignment in System V. (I haven't looked at other ABIs yet.)
source: https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-1.1.pdf |
Currently, the FFI supports
int8
-int64
,uint8
-uint32
,intptr
,double
, andfloat
as native types. These are supported by having them available in the API and handling their size and alignment correctly in structs and trampolines.However, the full ABI's also include packed data for SSE, with
__m128
etc. We could add those to the FFI.The text was updated successfully, but these errors were encountered: