]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/simd-intrinsic-declaration-type.rs
Imported Upstream version 1.5.0+dfsg1
[rustc.git] / src / test / compile-fail / simd-intrinsic-declaration-type.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.
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
11 #![feature(repr_simd, platform_intrinsics)]
12
13 #[repr(simd)]
14 struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
15 #[repr(simd)]
16 struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16);
17
18 #[repr(simd)]
19 struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
20 i8, i8, i8, i8, i8, i8, i8, i8);
21 #[repr(simd)]
22 struct i32x4(i32, i32, i32, i32);
23 #[repr(simd)]
24 struct f32x4(f32, f32, f32, f32);
25 #[repr(simd)]
26 struct i64x2(i64, i64);
27
28 // correct signatures work well
29 mod right {
30 use {i16x8, u16x8};
31 extern "platform-intrinsic" {
32 fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8;
33 fn x86_mm_adds_epu16(x: u16x8, y: u16x8) -> u16x8;
34 }
35 }
36 // but incorrect ones don't.
37
38 mod signedness {
39 use {i16x8, u16x8};
40 // signedness matters
41 extern "platform-intrinsic" {
42 fn x86_mm_adds_epi16(x: u16x8, y: u16x8) -> u16x8;
43 //~^ ERROR intrinsic argument 1 has wrong type
44 //~^^ ERROR intrinsic argument 2 has wrong type
45 //~^^^ ERROR intrinsic return value has wrong type
46 fn x86_mm_adds_epu16(x: i16x8, y: i16x8) -> i16x8;
47 //~^ ERROR intrinsic argument 1 has wrong type
48 //~^^ ERROR intrinsic argument 2 has wrong type
49 //~^^^ ERROR intrinsic return value has wrong type
50 }
51 }
52 // as do lengths
53 extern "platform-intrinsic" {
54 fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
55 //~^ ERROR intrinsic argument 1 has wrong type
56 //~^^ ERROR intrinsic argument 2 has wrong type
57 //~^^^ ERROR intrinsic return value has wrong type
58 }
59 // and so does int vs. float:
60 extern "platform-intrinsic" {
61 fn x86_mm_max_ps(x: i32x4, y: i32x4) -> i32x4;
62 //~^ ERROR intrinsic argument 1 has wrong type
63 //~^^ ERROR intrinsic argument 2 has wrong type
64 //~^^^ ERROR intrinsic return value has wrong type
65 }
66
67
68 fn main() {}