]> git.lizzy.rs Git - rust.git/blob - tests/run-make-fulldeps/simd-ffi/simd.rs
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
[rust.git] / tests / run-make-fulldeps / simd-ffi / simd.rs
1 // ensures that public symbols are not removed completely
2 #![crate_type = "lib"]
3 // we can compile to a variety of platforms, because we don't need
4 // cross-compiled standard libraries.
5 #![feature(no_core, auto_traits)]
6 #![no_core]
7 #![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]
8
9 #[derive(Copy)]
10 #[repr(simd)]
11 pub struct f32x4(f32, f32, f32, f32);
12
13 extern "C" {
14     #[link_name = "llvm.sqrt.v4f32"]
15     fn vsqrt(x: f32x4) -> f32x4;
16 }
17
18 pub fn foo(x: f32x4) -> f32x4 {
19     unsafe { vsqrt(x) }
20 }
21
22 #[derive(Copy)]
23 #[repr(simd)]
24 pub struct i32x4(i32, i32, i32, i32);
25
26 extern "C" {
27     // _mm_sll_epi32
28     #[cfg(any(target_arch = "x86", target_arch = "x86-64"))]
29     #[link_name = "llvm.x86.sse2.psll.d"]
30     fn integer(a: i32x4, b: i32x4) -> i32x4;
31
32     // vmaxq_s32
33     #[cfg(target_arch = "arm")]
34     #[link_name = "llvm.arm.neon.vmaxs.v4i32"]
35     fn integer(a: i32x4, b: i32x4) -> i32x4;
36     // vmaxq_s32
37     #[cfg(target_arch = "aarch64")]
38     #[link_name = "llvm.aarch64.neon.maxs.v4i32"]
39     fn integer(a: i32x4, b: i32x4) -> i32x4;
40
41     // just some substitute foreign symbol, not an LLVM intrinsic; so
42     // we still get type checking, but not as detailed as (ab)using
43     // LLVM.
44     #[cfg(not(any(
45         target_arch = "x86",
46         target_arch = "x86-64",
47         target_arch = "arm",
48         target_arch = "aarch64"
49     )))]
50     fn integer(a: i32x4, b: i32x4) -> i32x4;
51 }
52
53 pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
54     unsafe { integer(a, b) }
55 }
56
57 #[lang = "sized"]
58 pub trait Sized {}
59
60 #[lang = "copy"]
61 pub trait Copy {}
62
63 impl Copy for f32 {}
64 impl Copy for i32 {}
65
66 pub mod marker {
67     pub use Copy;
68 }
69
70 #[lang = "freeze"]
71 auto trait Freeze {}
72
73 #[macro_export]
74 #[rustc_builtin_macro]
75 macro_rules! Copy {
76     () => {};
77 }
78 #[macro_export]
79 #[rustc_builtin_macro]
80 macro_rules! derive {
81     () => {};
82 }