From 4748587a7743f297ff7550b51dc7dfe4ef7c67ee Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Nov 2016 15:23:19 +0100 Subject: [PATCH] fix creation of simd types --- src/interpreter/mod.rs | 7 ++++ .../simd-intrinsic-generic-elements.rs | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/run-pass/simd-intrinsic-generic-elements.rs diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index a431a7111a1..3c4900c054f 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -570,6 +570,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } } + Vector { element, count } => { + let elem_size = element.size(&self.tcx.data_layout).bytes(); + debug_assert_eq!(count, operands.len() as u64); + let offsets = (0..).map(|i| i * elem_size); + self.assign_fields(dest, offsets, operands)?; + } + _ => return Err(EvalError::Unimplemented(format!("can't handle destination layout {:?} when assigning {:?}", dest_layout, kind))), } } diff --git a/tests/run-pass/simd-intrinsic-generic-elements.rs b/tests/run-pass/simd-intrinsic-generic-elements.rs new file mode 100644 index 00000000000..36567f4c033 --- /dev/null +++ b/tests/run-pass/simd-intrinsic-generic-elements.rs @@ -0,0 +1,42 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x2(i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x3(i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x8(i32, i32, i32, i32, + i32, i32, i32, i32); + +fn main() { + let _x2 = i32x2(20, 21); + let _x3 = i32x3(30, 31, 32); + let _x4 = i32x4(40, 41, 42, 43); + let _x8 = i32x8(80, 81, 82, 83, 84, 85, 86, 87); + + let _y2 = i32x2(120, 121); + let _y3 = i32x3(130, 131, 132); + let _y4 = i32x4(140, 141, 142, 143); + let _y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187); + +}