]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/simd-intrinsic-generic-elements.rs
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.
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.
11 #![feature(repr_simd, platform_intrinsics, rustc_attrs)]
14 #[derive(Copy, Clone)]
15 #[allow(non_camel_case_types)]
16 struct i32x2(i32, i32);
18 #[derive(Copy, Clone)]
19 #[allow(non_camel_case_types)]
20 struct i32x3(i32, i32, i32);
22 #[derive(Copy, Clone)]
23 #[allow(non_camel_case_types)]
24 struct i32x4(i32, i32, i32, i32);
26 #[derive(Copy, Clone)]
27 #[allow(non_camel_case_types)]
28 struct i32x8(i32, i32, i32, i32,
32 #[derive(Copy, Clone)]
33 #[allow(non_camel_case_types)]
34 struct f32x2(f32, f32);
36 #[derive(Copy, Clone)]
37 #[allow(non_camel_case_types)]
38 struct f32x3(f32, f32, f32);
40 #[derive(Copy, Clone)]
41 #[allow(non_camel_case_types)]
42 struct f32x4(f32, f32, f32, f32);
44 #[derive(Copy, Clone)]
45 #[allow(non_camel_case_types)]
46 struct f32x8(f32, f32, f32, f32,
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
;
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
;
59 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
61 let x
= i32x4(0, 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`
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`
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`
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