]>
Commit | Line | Data |
---|---|---|
e9174d1e SL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
54a0048b | 11 | #![feature(repr_simd, platform_intrinsics, rustc_attrs)] |
e9174d1e SL |
12 | |
13 | #[repr(simd)] | |
14 | #[derive(Copy, Clone)] | |
15 | #[allow(non_camel_case_types)] | |
16 | struct i32x2(i32, i32); | |
17 | #[repr(simd)] | |
18 | #[derive(Copy, Clone)] | |
19 | #[allow(non_camel_case_types)] | |
20 | struct i32x3(i32, i32, i32); | |
21 | #[repr(simd)] | |
22 | #[derive(Copy, Clone)] | |
23 | #[allow(non_camel_case_types)] | |
24 | struct i32x4(i32, i32, i32, i32); | |
25 | #[repr(simd)] | |
26 | #[derive(Copy, Clone)] | |
27 | #[allow(non_camel_case_types)] | |
28 | struct i32x8(i32, i32, i32, i32, | |
29 | i32, i32, i32, i32); | |
30 | ||
31 | #[repr(simd)] | |
32 | #[derive(Copy, Clone)] | |
33 | #[allow(non_camel_case_types)] | |
34 | struct f32x2(f32, f32); | |
35 | #[repr(simd)] | |
36 | #[derive(Copy, Clone)] | |
37 | #[allow(non_camel_case_types)] | |
38 | struct f32x3(f32, f32, f32); | |
39 | #[repr(simd)] | |
40 | #[derive(Copy, Clone)] | |
41 | #[allow(non_camel_case_types)] | |
42 | struct f32x4(f32, f32, f32, f32); | |
43 | #[repr(simd)] | |
44 | #[derive(Copy, Clone)] | |
45 | #[allow(non_camel_case_types)] | |
46 | struct f32x8(f32, f32, f32, f32, | |
47 | f32, f32, f32, f32); | |
48 | ||
49 | extern "platform-intrinsic" { | |
50 | fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; | |
51 | fn simd_extract<T, E>(x: T, idx: u32) -> E; | |
52 | ||
53 | fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U; | |
54 | fn simd_shuffle3<T, U>(x: T, y: T, idx: [u32; 3]) -> U; | |
55 | fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U; | |
56 | fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U; | |
57 | } | |
58 | ||
54a0048b | 59 | #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls. |
e9174d1e SL |
60 | fn main() { |
61 | let x = i32x4(0, 0, 0, 0); | |
62 | ||
63 | unsafe { | |
64 | simd_insert(0, 0, 0); | |
65 | //~^ ERROR expected SIMD input type, found non-SIMD `i32` | |
66 | simd_insert(x, 0, 1.0); | |
67 | //~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64` | |
68 | simd_extract::<_, f32>(x, 0); | |
69 | //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32` | |
70 | ||
71 | simd_shuffle2::<i32, i32>(0, 0, [0; 2]); | |
72 | //~^ ERROR expected SIMD input type, found non-SIMD `i32` | |
73 | simd_shuffle3::<i32, i32>(0, 0, [0; 3]); | |
74 | //~^ ERROR expected SIMD input type, found non-SIMD `i32` | |
75 | simd_shuffle4::<i32, i32>(0, 0, [0; 4]); | |
76 | //~^ ERROR expected SIMD input type, found non-SIMD `i32` | |
77 | simd_shuffle8::<i32, i32>(0, 0, [0; 8]); | |
78 | //~^ ERROR expected SIMD input type, found non-SIMD `i32` | |
79 | ||
80 | simd_shuffle2::<_, f32x2>(x, x, [0; 2]); | |
81 | //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` | |
82 | simd_shuffle3::<_, f32x3>(x, x, [0; 3]); | |
83 | //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32` | |
84 | simd_shuffle4::<_, f32x4>(x, x, [0; 4]); | |
85 | //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` | |
86 | simd_shuffle8::<_, f32x8>(x, x, [0; 8]); | |
87 | //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` | |
88 | ||
89 | simd_shuffle2::<_, i32x8>(x, x, [0; 2]); | |
90 | //~^ ERROR expected return type of length 2, found `i32x8` with length 8 | |
91 | simd_shuffle3::<_, i32x4>(x, x, [0; 3]); | |
92 | //~^ ERROR expected return type of length 3, found `i32x4` with length 4 | |
93 | simd_shuffle4::<_, i32x3>(x, x, [0; 4]); | |
94 | //~^ ERROR expected return type of length 4, found `i32x3` with length 3 | |
95 | simd_shuffle8::<_, i32x2>(x, x, [0; 8]); | |
96 | //~^ ERROR expected return type of length 8, found `i32x2` with length 2 | |
97 | } | |
98 | } |