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