]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
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. | |
fc512014 | 5 | #![feature(no_core, auto_traits)] |
e9174d1e | 6 | #![no_core] |
416331ca | 7 | #![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)] |
85aaf69f | 8 | |
85aaf69f | 9 | #[derive(Copy)] |
e9174d1e | 10 | #[repr(simd)] |
85aaf69f SL |
11 | pub struct f32x4(f32, f32, f32, f32); |
12 | ||
dfeec247 | 13 | extern "C" { |
85aaf69f SL |
14 | #[link_name = "llvm.sqrt.v4f32"] |
15 | fn vsqrt(x: f32x4) -> f32x4; | |
16 | } | |
17 | ||
18 | pub fn foo(x: f32x4) -> f32x4 { | |
dfeec247 | 19 | unsafe { vsqrt(x) } |
85aaf69f SL |
20 | } |
21 | ||
85aaf69f | 22 | #[derive(Copy)] |
e9174d1e | 23 | #[repr(simd)] |
85aaf69f SL |
24 | pub struct i32x4(i32, i32, i32, i32); |
25 | ||
dfeec247 | 26 | extern "C" { |
85aaf69f | 27 | // _mm_sll_epi32 |
dfeec247 | 28 | #[cfg(any(target_arch = "x86", target_arch = "x86-64"))] |
85aaf69f SL |
29 | #[link_name = "llvm.x86.sse2.psll.d"] |
30 | fn integer(a: i32x4, b: i32x4) -> i32x4; | |
31 | ||
32 | // vmaxq_s32 | |
9cc50fc6 | 33 | #[cfg(target_arch = "arm")] |
85aaf69f SL |
34 | #[link_name = "llvm.arm.neon.vmaxs.v4i32"] |
35 | fn integer(a: i32x4, b: i32x4) -> i32x4; | |
36 | // vmaxq_s32 | |
9cc50fc6 | 37 | #[cfg(target_arch = "aarch64")] |
85aaf69f SL |
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. | |
dfeec247 XL |
44 | #[cfg(not(any( |
45 | target_arch = "x86", | |
46 | target_arch = "x86-64", | |
47 | target_arch = "arm", | |
48 | target_arch = "aarch64" | |
49 | )))] | |
85aaf69f SL |
50 | fn integer(a: i32x4, b: i32x4) -> i32x4; |
51 | } | |
52 | ||
53 | pub fn bar(a: i32x4, b: i32x4) -> i32x4 { | |
dfeec247 | 54 | unsafe { integer(a, b) } |
85aaf69f SL |
55 | } |
56 | ||
57 | #[lang = "sized"] | |
dfeec247 | 58 | pub trait Sized {} |
85aaf69f SL |
59 | |
60 | #[lang = "copy"] | |
dfeec247 | 61 | pub trait Copy {} |
85aaf69f | 62 | |
83c7162d XL |
63 | impl Copy for f32 {} |
64 | impl Copy for i32 {} | |
65 | ||
e9174d1e SL |
66 | pub mod marker { |
67 | pub use Copy; | |
85aaf69f | 68 | } |
cc61c64b XL |
69 | |
70 | #[lang = "freeze"] | |
2c00a5a8 | 71 | auto trait Freeze {} |
416331ca XL |
72 | |
73 | #[macro_export] | |
74 | #[rustc_builtin_macro] | |
dfeec247 XL |
75 | macro_rules! Copy { |
76 | () => {}; | |
77 | } | |
6a06907d XL |
78 | #[macro_export] |
79 | #[rustc_builtin_macro] | |
80 | macro_rules! derive { | |
81 | () => {}; | |
82 | } |