]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/simd-intrinsic-generic-arithmetic.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / compile-fail / simd-intrinsic-generic-arithmetic.rs
CommitLineData
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
a7813a04 11#![feature(repr_simd, platform_intrinsics)]
e9174d1e
SL
12#![allow(non_camel_case_types)]
13#[repr(simd)]
14#[derive(Copy, Clone)]
15pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
16
17#[repr(simd)]
18#[derive(Copy, Clone)]
19pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
20
21#[repr(simd)]
22#[derive(Copy, Clone)]
23pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
24
25extern "platform-intrinsic" {
26 fn simd_add<T>(x: T, y: T) -> T;
27 fn simd_sub<T>(x: T, y: T) -> T;
28 fn simd_mul<T>(x: T, y: T) -> T;
29 fn simd_div<T>(x: T, y: T) -> T;
abe05a73 30 fn simd_rem<T>(x: T, y: T) -> T;
e9174d1e
SL
31 fn simd_shl<T>(x: T, y: T) -> T;
32 fn simd_shr<T>(x: T, y: T) -> T;
33 fn simd_and<T>(x: T, y: T) -> T;
34 fn simd_or<T>(x: T, y: T) -> T;
35 fn simd_xor<T>(x: T, y: T) -> T;
36}
37
38fn main() {
39 let x = i32x4(0, 0, 0, 0);
40 let y = u32x4(0, 0, 0, 0);
41 let z = f32x4(0.0, 0.0, 0.0, 0.0);
42
43 unsafe {
44 simd_add(x, x);
45 simd_add(y, y);
46 simd_add(z, z);
47 simd_sub(x, x);
48 simd_sub(y, y);
49 simd_sub(z, z);
50 simd_mul(x, x);
51 simd_mul(y, y);
52 simd_mul(z, z);
abe05a73
XL
53 simd_div(x, x);
54 simd_div(y, y);
e9174d1e 55 simd_div(z, z);
abe05a73
XL
56 simd_rem(x, x);
57 simd_rem(y, y);
58 simd_rem(z, z);
e9174d1e
SL
59
60 simd_shl(x, x);
61 simd_shl(y, y);
62 simd_shr(x, x);
63 simd_shr(y, y);
64 simd_and(x, x);
65 simd_and(y, y);
66 simd_or(x, x);
67 simd_or(y, y);
68 simd_xor(x, x);
69 simd_xor(y, y);
70
71
72 simd_add(0, 0);
73 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
74 simd_sub(0, 0);
75 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
76 simd_mul(0, 0);
77 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
78 simd_div(0, 0);
79 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
80 simd_shl(0, 0);
81 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
82 simd_shr(0, 0);
83 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
84 simd_and(0, 0);
85 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
86 simd_or(0, 0);
87 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
88 simd_xor(0, 0);
89 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
90
91
e9174d1e
SL
92 simd_shl(z, z);
93//~^ ERROR unsupported operation on `f32x4` with element `f32`
94 simd_shr(z, z);
95//~^ ERROR unsupported operation on `f32x4` with element `f32`
96 simd_and(z, z);
97//~^ ERROR unsupported operation on `f32x4` with element `f32`
98 simd_or(z, z);
99//~^ ERROR unsupported operation on `f32x4` with element `f32`
100 simd_xor(z, z);
101//~^ ERROR unsupported operation on `f32x4` with element `f32`
102 }
103}