]> git.proxmox.com Git - rustc.git/blame - src/test/run-make-fulldeps/simd-ffi/simd.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / test / run-make-fulldeps / simd-ffi / simd.rs
CommitLineData
85aaf69f
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
11// ensures that public symbols are not removed completely
12#![crate_type = "lib"]
13// we can compile to a variety of platforms, because we don't need
14// cross-compiled standard libraries.
cc61c64b 15#![feature(no_core, optin_builtin_traits)]
e9174d1e 16#![no_core]
85aaf69f 17
e9174d1e 18#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items)]
85aaf69f
SL
19
20
21#[repr(C)]
22#[derive(Copy)]
e9174d1e 23#[repr(simd)]
85aaf69f
SL
24pub struct f32x4(f32, f32, f32, f32);
25
26
27extern {
28 #[link_name = "llvm.sqrt.v4f32"]
29 fn vsqrt(x: f32x4) -> f32x4;
30}
31
32pub fn foo(x: f32x4) -> f32x4 {
33 unsafe {vsqrt(x)}
34}
35
36#[repr(C)]
37#[derive(Copy)]
e9174d1e 38#[repr(simd)]
85aaf69f
SL
39pub struct i32x4(i32, i32, i32, i32);
40
41
42extern {
43 // _mm_sll_epi32
44 #[cfg(any(target_arch = "x86",
45 target_arch = "x86-64"))]
46 #[link_name = "llvm.x86.sse2.psll.d"]
47 fn integer(a: i32x4, b: i32x4) -> i32x4;
48
49 // vmaxq_s32
9cc50fc6 50 #[cfg(target_arch = "arm")]
85aaf69f
SL
51 #[link_name = "llvm.arm.neon.vmaxs.v4i32"]
52 fn integer(a: i32x4, b: i32x4) -> i32x4;
53 // vmaxq_s32
9cc50fc6 54 #[cfg(target_arch = "aarch64")]
85aaf69f
SL
55 #[link_name = "llvm.aarch64.neon.maxs.v4i32"]
56 fn integer(a: i32x4, b: i32x4) -> i32x4;
57
58 // just some substitute foreign symbol, not an LLVM intrinsic; so
59 // we still get type checking, but not as detailed as (ab)using
60 // LLVM.
61 #[cfg(not(any(target_arch = "x86",
62 target_arch = "x86-64",
63 target_arch = "arm",
64 target_arch = "aarch64")))]
65 fn integer(a: i32x4, b: i32x4) -> i32x4;
66}
67
68pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
69 unsafe {integer(a, b)}
70}
71
72#[lang = "sized"]
9346a6ac 73pub trait Sized { }
85aaf69f
SL
74
75#[lang = "copy"]
9346a6ac 76pub trait Copy { }
85aaf69f 77
83c7162d
XL
78impl Copy for f32 {}
79impl Copy for i32 {}
80
e9174d1e
SL
81pub mod marker {
82 pub use Copy;
85aaf69f 83}
cc61c64b
XL
84
85#[lang = "freeze"]
2c00a5a8 86auto trait Freeze {}