diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-03-26 10:22:37 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-03-26 10:22:37 +0000 |
| commit | c3ee03011962d53f44d9d0faf26260f914191cfc (patch) | |
| tree | 02d10ad56eebda5a3e2914b8954cd2a7dca3b08d | |
| parent | eed1f754151965c4f9f7eef877801043101b83e1 (diff) | |
| download | rust-c3ee03011962d53f44d9d0faf26260f914191cfc.tar.gz rust-c3ee03011962d53f44d9d0faf26260f914191cfc.zip | |
Fix passing and returning vector types
| -rw-r--r-- | example/std_example.rs | 10 | ||||
| -rw-r--r-- | src/value_and_place.rs | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/example/std_example.rs b/example/std_example.rs index c86063f60b9..ab4045d11a6 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,4 +1,4 @@ -#![feature(core_intrinsics, generators, generator_trait, is_sorted)] +#![feature(core_intrinsics, generators, generator_trait, is_sorted, repr_simd)] #[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; @@ -153,12 +153,20 @@ fn main() { enum Never {} } + + foo(I64X2(0, 0)); } fn panic(_: u128) { panic!(); } +#[repr(simd)] +struct I64X2(i64, i64); + +#[allow(improper_ctypes_definitions)] +extern "C" fn foo(_a: I64X2) {} + #[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_simd() { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 622ad2ae78a..cd24106257a 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -165,6 +165,9 @@ impl<'tcx> CValue<'tcx> { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { Abi::Scalar(scalar) => scalar_to_clif_type(fx.tcx, scalar), + Abi::Vector { element, count } => scalar_to_clif_type(fx.tcx, element) + .by(u32::try_from(count).unwrap()) + .unwrap(), _ => unreachable!("{:?}", layout.ty), }; let mut flags = MemFlags::new(); |
