-
Notifications
You must be signed in to change notification settings - Fork 287
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
Can't get the correct return type of llvm link #1143
Comments
Except for the padding using the #![feature(link_llvm_intrinsics, aarch64_target_feature, stdsimd, simd_ffi, repr_simd, arm_target_feature, platform_intrinsics, abi_unadjusted)]
#[cfg(target_arch = "aarch64")]
use core::arch::aarch64::*;
#[cfg(target_arch = "arm")]
use core::arch::arm::*;
pub struct int16x4x2_t(pub int16x4_t, pub int16x4_t);
pub unsafe fn vld1_s16_x2(ptr: *const i16) -> int16x4x2_t {
#[allow(improper_ctypes)]
extern "unadjusted" {
#[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1x2.v4i16.p0i16")]
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.ld1x2.v4i16.p0i16")]
fn vld1_s16_x2_(ptr: *const i16) -> (int16x4_t, int16x4_t);
}
let (a, b) = vld1_s16_x2_(ptr);
int16x4x2_t(a, b)
}
|
having a repr(rust) type as the output type of the inner function call seems pretty dodgy |
@Amanieu I think this is a llvm bug? Considering that it blocked the implementation of about 500 neon instructions, can we have a solution to it? |
This is a bug in rustc: with the |
The |
…mit_zero_sized_padding, r=eddyb LLVM codegen: Don't emit zero-sized padding for fields Currently padding is emitted before fields of a struct and at the end of the struct regardless of the ABI. Even if no padding is required zero-sized padding fields are emitted. This is not useful and - more importantly - it make it impossible to generate the exact vector types that LLVM expects for certain ARM SIMD intrinsics. This change should unblock the implementation of many ARM intrinsics using the `unadjusted` ABI, see rust-lang/stdarch#1143 (comment). This is a proof of concept only because the field lookup now takes O(number of fields) time compared to O(1) before since it recalculates the mapping at every lookup. I would like to find out how big the performance impact actually is before implementing caching or restricting this behavior to the `unadjusted` ABI. cc `@SparrowLii` `@bjorn3` ([Discussion on internals](https://internals.rust-lang.org/t/feature-request-add-a-way-in-rustc-for-generating-struct-type-llvm-ir-without-paddings/15007))
That should work with the |
Yes. Thanks again for solving this problem, I plan to add related instructions this week( If no one else does it) |
It seems that here is a new problem in armv7: https://rust.godbolt.org/z/E3G9rhrda |
You need to enable the |
Look the following implementation of vld1_s16_x2 neon instruction:
godbolt
the return type of
vld1x2.v4i16.p0i16
should be{<4 x i16>, <4 x i16>}
But if we do a similar implementation in rust:
gotbolt
llvm will change the return type to the wrong
[ 2 x <i8 x 8> ]
. As a result, we cannot implement thevld1_s16_x2
instruction.The text was updated successfully, but these errors were encountered: