Skip to content

Commit

Permalink
Fix passing and returning vector types
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Mar 26, 2023
1 parent eed1f75 commit c3ee030
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion example/std_example.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c3ee030

Please sign in to comment.