| 1 |
//! Architecture-specific support for x86-32 and x86-64 with SSE2 |
| 2 |
|
| 3 |
mod detect; |
| 4 |
mod fma; |
| 5 |
|
| 6 |
pub use fma::{fma, fmaf}; |
| 7 |
|
| 8 |
pub fn sqrtf(mut x: f32) -> f32 { |
| 9 |
// SAFETY: `sqrtss` is part of `sse2`, which this module is gated behind. It has no memory |
| 10 |
// access or side effects. |
| 11 |
unsafe { |
| 12 |
core::arch::asm!( |
| 13 |
"sqrtss {x}, {x}", |
| 14 |
x = inout(xmm_reg) x, |
| 15 |
options(nostack, nomem, pure), |
| 16 |
) |
| 17 |
}; |
| 18 |
x |
| 19 |
} |
| 20 |
|
| 21 |
pub fn sqrt(mut x: f64) -> f64 { |
| 22 |
// SAFETY: `sqrtsd` is part of `sse2`, which this module is gated behind. It has no memory |
| 23 |
// access or side effects. |
| 24 |
unsafe { |
| 25 |
core::arch::asm!( |
| 26 |
"sqrtsd {x}, {x}", |
| 27 |
x = inout(xmm_reg) x, |
| 28 |
options(nostack, nomem, pure), |
| 29 |
) |
| 30 |
}; |
| 31 |
x |
| 32 |
} |