1//! Architecture-specific routines and operations.
2//!
3//! LLVM will already optimize calls to some of these in cases that there are hardware
4//! instructions. Providing an implementation here just ensures that the faster implementation
5//! is used when calling the function directly. This helps anyone who uses `libm` directly, as
6//! well as improving things when these routines are called as part of other implementations.
7
8// Most implementations should be defined here, to ensure they are not made available when
9// soft floats are required.
10#[cfg(arch_enabled)]
11cfg_if! {
12 if #[cfg(all(target_arch = "wasm32", intrinsics_enabled))] {
13 mod wasm32;
14 pub use wasm32::{
15 ceil, ceilf, fabs, fabsf, floor, floorf, rint, rintf, sqrt, sqrtf, trunc, truncf,
16 };
17 } else if #[cfg(target_feature = "sse2")] {
18 mod i686;
19 pub use i686::{sqrt, sqrtf};
20 } else if #[cfg(all(
21 target_arch = "aarch64", // TODO: also arm64ec?
22 target_feature = "neon",
23 target_endian = "little", // see https://github.com/rust-lang/stdarch/issues/1484
24 ))] {
25 mod aarch64;
26 pub use aarch64::{rint, rintf};
27 }
28}
29
30// There are certain architecture-specific implementations that are needed for correctness
31// even with `force-soft-float`. These are configured here.
32cfg_if! {
33 if #[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] {
34 mod i586;
35 pub use i586::{ceil, floor};
36 }
37}
38