You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On Android platform aarch64 ABI does not return vec4 correctly #773
platform: x86_64-pc-mingw64
toolchain: aarch64-unknown-linux-android
compiler: clang version 12.0.5
Problems Description
When calling the C++ member function glm::vec4 imageview::get_background_color() through ffi, the returnvalue parameter of the ffi_call can only get the first member (x) of vec4, and through debug, it is found that the st4 { v0.s, v1.s, v2.s, v3.s }[0], [x3] instructions used in sysV.S copy the return value. I debugged in lldb and found that the four members of vec4 are placed in the v0 register, not v0, v1, v2, v3 each stored in a float, changed to stp x0, x1, [x3] instructions can correctly get the return value. I also tried to return to vec3, and found that the three members of vec3 have stored v0, v1, v2 registers respectively, which can work correctly. Is there a way to get st4 to work correctly?
PS: the type of returnvalue passed to the ffi_call is:
type = new ffi_type;
memset(type, 0, sizeof(ffi_type));
type->type = FFI_TYPE_STRUCT;
type->elements = new ffi_type * [5];
type->elements[0] = &ffi_type_float;
type->elements[1] = &ffi_type_float;
type->elements[2] = &ffi_type_float;
type->elements[3] = &ffi_type_float;
type->elements[4] = nullptr;
Can you please validate that I wrote them correctly for this problem?
They are passing on aarch64 Linux, so this must be an ABI difference on Android (or the tests are wrong).
They are passing on my Android aarch64 platform.
There are some differences between your tests and my case.
The underlying type of glm::vec4 is float32x4_t( float32_t attribute((ext_vector_type(4))) ), which is defined in arm_neon.h.
I don't know how to describe float32x4_t with ffi_type_xxx.
Activity
atgreen commentedon Apr 3, 2023
I added two tests: 2d63cee
Can you please validate that I wrote them correctly for this problem?
They are passing on aarch64 Linux, so this must be an ABI difference on Android (or the tests are wrong).
jilinxiaohuo commentedon Apr 4, 2023
They are passing on my Android aarch64 platform.
There are some differences between your tests and my case.
The underlying type of glm::vec4 is float32x4_t( float32_t attribute((ext_vector_type(4))) ), which is defined in arm_neon.h.
I don't know how to describe float32x4_t with ffi_type_xxx.
atgreen commentedon Apr 5, 2023
Ok, got it. There was work in progress for this feature. It stalled, but you might want to look to see how close it is: #414
core: add FFI_TYPE_VECTOR fundamental type with computed layout
aarch64: marshal vector (SIMD) types per AAPCS64
testsuite: add libffi.vector suite for vector (SIMD) types