]>
git.proxmox.com Git - rustc.git/blob - library/stdarch/crates/core_arch/src/mod.rs
3 #![cfg_attr(not(bootstrap), allow(automatic_links))]
7 #[cfg(any(target_arch = "arm", target_arch = "aarch64", doc))]
12 #[doc = include_str!("core_arch_docs.md")]
13 #[stable(feature = "simd_arch", since = "1.27.0")]
15 /// Platform-specific intrinsics for the `x86` platform.
17 /// See the [module documentation](../index.html) for more details.
18 #[cfg(any(target_arch = "x86", doc))]
19 #[doc(cfg(target_arch = "x86"))]
20 #[stable(feature = "simd_x86", since = "1.27.0")]
22 #[stable(feature = "simd_x86", since = "1.27.0")]
23 pub use crate::core_arch
::x86
::*;
26 /// Platform-specific intrinsics for the `x86_64` platform.
28 /// See the [module documentation](../index.html) for more details.
29 #[cfg(any(target_arch = "x86_64", doc))]
30 #[doc(cfg(target_arch = "x86_64"))]
31 #[stable(feature = "simd_x86", since = "1.27.0")]
33 #[stable(feature = "simd_x86", since = "1.27.0")]
34 pub use crate::core_arch
::x86
::*;
35 #[stable(feature = "simd_x86", since = "1.27.0")]
36 pub use crate::core_arch
::x86_64
::*;
39 /// Platform-specific intrinsics for the `arm` platform.
41 /// See the [module documentation](../index.html) for more details.
42 #[cfg(any(target_arch = "arm", doc))]
43 #[doc(cfg(target_arch = "arm"))]
44 #[unstable(feature = "stdsimd", issue = "27731")]
46 pub use crate::core_arch
::arm
::*;
49 /// Platform-specific intrinsics for the `aarch64` platform.
51 /// See the [module documentation](../index.html) for more details.
52 #[cfg(any(target_arch = "aarch64", doc))]
53 #[doc(cfg(target_arch = "aarch64"))]
54 #[unstable(feature = "stdsimd", issue = "27731")]
56 pub use crate::core_arch
::{aarch64::*, arm::*}
;
59 /// Platform-specific intrinsics for the `wasm32` platform.
61 /// This module provides intrinsics specific to the WebAssembly
62 /// architecture. Here you'll find intrinsics necessary for leveraging
63 /// WebAssembly proposals such as [atomics] and [simd]. These proposals are
64 /// evolving over time and as such the support here is unstable and requires
65 /// the nightly channel. As WebAssembly proposals stabilize these functions
66 /// will also become stable.
68 /// [atomics]: https://github.com/webassembly/threads
69 /// [simd]: https://github.com/webassembly/simd
71 /// See the [module documentation](../index.html) for general information
72 /// about the `arch` module and platform intrinsics.
76 /// The [threads proposal][atomics] for WebAssembly adds a number of
77 /// instructions for dealing with multithreaded programs. Atomic
78 /// instructions can all be generated through `std::sync::atomic` types, but
79 /// some instructions have no equivalent in Rust such as
80 /// `memory.atomic.notify` so this module will provide these intrinsics.
82 /// At this time, however, these intrinsics are only available **when the
83 /// standard library itself is compiled with atomics**. Compiling with
84 /// atomics is not enabled by default and requires passing
85 /// `-Ctarget-feature=+atomics` to rustc. The standard library shipped via
86 /// `rustup` is not compiled with atomics. To get access to these intrinsics
87 /// you'll need to compile the standard library from source with the
88 /// requisite compiler flags.
92 /// The [simd proposal][simd] for WebAssembly adds a new `v128` type for a
93 /// 128-bit SIMD register. It also adds a large array of instructions to
94 /// operate on the `v128` type to perform data processing. The SIMD proposal
95 /// has been in progress for quite some time and many instructions have come
96 /// and gone. This module attempts to keep up with the proposal, but if you
97 /// notice anything awry please feel free to [open an
98 /// issue](https://github.com/rust-lang/stdarch/issues/new).
100 /// It's important to be aware that the current state of development of SIMD
101 /// in WebAssembly is still somewhat early days. There's lots of pieces to
102 /// demo and prototype with, but discussions and support are still in
103 /// progress. There's a number of pitfalls and gotchas in various places,
104 /// which will attempt to be documented here, but there may be others
107 /// Using SIMD is intended to be similar to as you would on `x86_64`, for
108 /// example. You'd write a function such as:
111 /// #[cfg(target_arch = "wasm32")]
112 /// #[target_feature(enable = "simd128")]
113 /// unsafe fn uses_simd() {
114 /// use std::arch::wasm32::*;
119 /// Unlike `x86_64`, however, WebAssembly does not currently have dynamic
120 /// detection at runtime as to whether SIMD is supported (this is one of the
121 /// motivators for the [conditional sections proposal][condsections], but
122 /// that is still pretty early days). This means that your binary will
123 /// either have SIMD and can only run on engines which support SIMD, or it
124 /// will not have SIMD at all. For compatibility the standard library itself
125 /// does not use any SIMD internally. Determining how best to ship your
126 /// WebAssembly binary with SIMD is largely left up to you as it can can be
127 /// pretty nuanced depending on your situation.
129 /// [condsections]: https://github.com/webassembly/conditional-sections
131 /// To enable SIMD support at compile time you need to do one of two things:
133 /// * First you can annotate functions with `#[target_feature(enable =
134 /// "simd128")]`. This causes just that one function to have SIMD support
135 /// available to it, and intrinsics will get inlined as usual in this
138 /// * Second you can compile your program with `-Ctarget-feature=+simd128`.
139 /// This compilation flag blanket enables SIMD support for your entire
140 /// compilation. Note that this does not include the standard library
141 /// unless you recompile the standard library.
143 /// If you enable SIMD via either of these routes then you'll have a
144 /// WebAssembly binary that uses SIMD instructions, and you'll need to ship
145 /// that accordingly. Also note that if you call SIMD intrinsics but don't
146 /// enable SIMD via either of these mechanisms, you'll still have SIMD
147 /// generated in your program. This means to generate a binary without SIMD
148 /// you'll need to avoid both options above plus calling into any intrinsics
151 /// > **Note**: Due to
152 /// > [rust-lang/rust#74320](https://github.com/rust-lang/rust/issues/74320)
153 /// > it's recommended to compile your entire program with SIMD support
154 /// > (using `RUSTFLAGS`) or otherwise functions may not be inlined
157 /// > **Note**: LLVM's SIMD support is actually split into two features:
158 /// > `simd128` and `unimplemented-simd128`. Rust code can enable `simd128`
159 /// > with `#[target_feature]` (and test for it with `#[cfg(target_feature =
160 /// > "simd128")]`, but it cannot enable `unimplemented-simd128`. The only
161 /// > way to enable this feature is to compile with
162 /// > `-Ctarget-feature=+simd128,+unimplemented-simd128`. This second
163 /// > feature enables more recent instructions implemented in LLVM which
164 /// > haven't always had enough time to make their way to runtimes.
165 #[cfg(any(target_arch = "wasm32", doc))]
166 #[doc(cfg(target_arch = "wasm32"))]
167 #[stable(feature = "simd_wasm32", since = "1.33.0")]
169 #[stable(feature = "simd_wasm32", since = "1.33.0")]
170 pub use crate::core_arch
::wasm32
::*;
173 /// Platform-specific intrinsics for the `mips` platform.
175 /// See the [module documentation](../index.html) for more details.
176 #[cfg(any(target_arch = "mips", doc))]
177 #[doc(cfg(target_arch = "mips"))]
178 #[unstable(feature = "stdsimd", issue = "27731")]
180 pub use crate::core_arch
::mips
::*;
183 /// Platform-specific intrinsics for the `mips64` platform.
185 /// See the [module documentation](../index.html) for more details.
186 #[cfg(any(target_arch = "mips64", doc))]
187 #[doc(cfg(target_arch = "mips64"))]
188 #[unstable(feature = "stdsimd", issue = "27731")]
190 pub use crate::core_arch
::mips
::*;
193 /// Platform-specific intrinsics for the `PowerPC` platform.
195 /// See the [module documentation](../index.html) for more details.
196 #[cfg(any(target_arch = "powerpc", doc))]
197 #[doc(cfg(target_arch = "powerpc"))]
198 #[unstable(feature = "stdsimd", issue = "27731")]
200 pub use crate::core_arch
::powerpc
::*;
203 /// Platform-specific intrinsics for the `PowerPC64` platform.
205 /// See the [module documentation](../index.html) for more details.
206 #[cfg(any(target_arch = "powerpc64", doc))]
207 #[doc(cfg(target_arch = "powerpc64"))]
208 #[unstable(feature = "stdsimd", issue = "27731")]
210 pub use crate::core_arch
::powerpc64
::*;
213 /// Platform-specific intrinsics for the `NVPTX` platform.
215 /// See the [module documentation](../index.html) for more details.
216 #[cfg(any(target_arch = "nvptx", target_arch = "nvptx64", doc))]
217 #[doc(cfg(any(target_arch = "nvptx", target_arch = "nvptx64")))]
218 #[unstable(feature = "stdsimd", issue = "27731")]
220 pub use crate::core_arch
::nvptx
::*;
226 #[cfg(any(target_arch = "x86", target_arch = "x86_64", doc))]
227 #[doc(cfg(any(target_arch = "x86", target_arch = "x86_64")))]
229 #[cfg(any(target_arch = "x86_64", doc))]
230 #[doc(cfg(target_arch = "x86_64"))]
233 #[cfg(any(target_arch = "aarch64", doc))]
234 #[doc(cfg(target_arch = "aarch64"))]
236 #[cfg(any(target_arch = "arm", target_arch = "aarch64", doc))]
237 #[doc(cfg(any(target_arch = "arm", target_arch = "aarch64")))]
240 #[cfg(any(target_arch = "wasm32", doc))]
241 #[doc(cfg(target_arch = "wasm32"))]
244 #[cfg(any(target_arch = "mips", target_arch = "mips64", doc))]
245 #[doc(cfg(any(target_arch = "mips", target_arch = "mips64")))]
248 #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64", doc))]
249 #[doc(cfg(any(target_arch = "powerpc", target_arch = "powerpc64")))]
252 #[cfg(any(target_arch = "powerpc64", doc))]
253 #[doc(cfg(target_arch = "powerpc64"))]
256 #[cfg(any(target_arch = "nvptx", target_arch = "nvptx64", doc))]
257 #[doc(cfg(any(target_arch = "nvptx", target_arch = "nvptx64")))]