2019-12-13 21:28:32 -06:00
|
|
|
// build-fail
|
|
|
|
|
2016-03-10 13:20:09 -06:00
|
|
|
#![feature(repr_simd, platform_intrinsics, rustc_attrs)]
|
2015-08-12 23:12:36 -05:00
|
|
|
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
struct i32x2(i32, i32);
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
struct i32x4(i32, i32, i32, i32);
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
struct i32x8(i32, i32, i32, i32,
|
|
|
|
i32, i32, i32, i32);
|
|
|
|
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
struct f32x2(f32, f32);
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
struct f32x4(f32, f32, f32, f32);
|
|
|
|
#[repr(simd)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
struct f32x8(f32, f32, f32, f32,
|
|
|
|
f32, f32, f32, f32);
|
|
|
|
|
|
|
|
extern "platform-intrinsic" {
|
|
|
|
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
|
|
|
|
fn simd_extract<T, E>(x: T, idx: u32) -> E;
|
|
|
|
|
2023-07-10 08:03:48 -05:00
|
|
|
fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
|
2015-08-12 23:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = i32x4(0, 0, 0, 0);
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
simd_insert(0, 0, 0);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
|
2015-08-12 23:12:36 -05:00
|
|
|
simd_insert(x, 0, 1.0);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64`
|
2015-08-12 23:12:36 -05:00
|
|
|
simd_extract::<_, f32>(x, 0);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32`
|
2015-08-12 23:12:36 -05:00
|
|
|
|
2021-05-12 10:08:45 -05:00
|
|
|
const IDX2: [u32; 2] = [0; 2];
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<i32, _, i32>(0, 0, IDX2);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
|
2021-05-12 10:08:45 -05:00
|
|
|
const IDX4: [u32; 4] = [0; 4];
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<i32, _, i32>(0, 0, IDX4);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
|
2021-05-12 10:08:45 -05:00
|
|
|
const IDX8: [u32; 8] = [0; 8];
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<i32, _, i32>(0, 0, IDX8);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected SIMD input type, found non-SIMD `i32`
|
2015-08-12 23:12:36 -05:00
|
|
|
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<_, _, f32x2>(x, x, IDX2);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<_, _, f32x4>(x, x, IDX4);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<_, _, f32x8>(x, x, IDX8);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
|
|
|
|
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<_, _, i32x8>(x, x, IDX2);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected return type of length 2, found `i32x8` with length 8
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<_, _, i32x8>(x, x, IDX4);
|
2021-01-23 15:31:43 -06:00
|
|
|
//~^ ERROR expected return type of length 4, found `i32x8` with length 8
|
2023-07-10 08:03:48 -05:00
|
|
|
simd_shuffle::<_, _, i32x2>(x, x, IDX8);
|
2015-08-14 17:20:22 -05:00
|
|
|
//~^ ERROR expected return type of length 8, found `i32x2` with length 2
|
2015-08-12 23:12:36 -05:00
|
|
|
}
|
|
|
|
}
|